Daily log - April 23, 2009
by Sean Cribbs
Application accepted. I learned how to use Javascript’s apply
method today (properly). For some context, I was using LowPro awesome DOM.Builder
functions to create some @option@s programmatically and insert them into a select
. The only thing I thought that is exceptionally quirky about the implementation is that the last argument to a “tagFunc
” appears to be an array of children. However on closer inspection, the tagFunc
actually takes any number of arguments after the attributes as children, but not an array. Unfortunately, since Javascript doesn’t have Ruby’s awesome “splat” operator (*
) for arrays, I had to find another way. Mozilla’s Developer Connection really helped out here. At first I was trying this:
Instead, this is what worked:
Yay for higher-order functions! UPDATE It seems Dan has corrected this issue in the LowPro available on GitHub. I’ll be upgrading!