MacBook, defective by design banner

title:
Put the knife down and take a green herb, dude.

descrip:
One feller's views on the state of everyday computer science & its application (and now, OTHER STUFF) who isn't rich enough to shell out for www.myfreakinfirst-andlast-name.com

Self-Pimpin':
Member of an email list?
You need The Digest Handler!!


FOR ENTERTAINMENT PURPOSES ONLY!!! Back-up your data and always wear white.
URLs I want to remember:
* Atari 2600 programming on your Mac
* joel on software (tip pt)
* resume, mostly for Google * Regular Expression Introduction (copy)
* gpl xbrowser API for dhtml
* mulder (old css tutorial)
* Using CommonDialog in VB 6 * Free zip utils
* that hardware vendor review site I forget about is here * Javascript 1.5 ref
* Read the bits about the zone * w3c.org index of HTML 4.01 elements
* Giant ASCII Textifier * Quick intro to Javascript
* Editable Firefox Page * Parsing str's in VB6
email if ya gotta, RSS if ya wanna RSS
 
 
Wednesday, January 11, 2012

Found Array.prototype.slice.apply in some inherited code. Why would you use the Array type's prototype method? Apparently to slice Array-like objects that aren't really arrays. Why Array's slice works with the non-but-almost-arrays, I don't know.

Understanding Array.prototype.slice.apply(arguments) in JavaScript � Sebastiano Armeli's Tech Blog:

There you go Array.prototype.slice.apply(arguments) converts arguments into an ARRAY.

Here we use one of the methods to call a function in JavaScript, the APPLY method, you can learn more about how to call a function in JS here.
So we apply the slice function to the first argument of the apply function(in this case “arguments”) and we know that the slice() method returns always an Array. We got our Array!


Similarly...

javascript - What's the use of Array.prototype.slice.call(array, 0)? - Stack Overflow:

The DOM usually returns a NodeList for most operations like getElementsByTagName.

Although a NodeList almost feels like an array, it is not. It has a length property like an array does, and a method item(index) to access an object at the given index (also accessible with the [index] notation), but that's where the similarity ends.

So to be able to use the wonderful array methods without rewriting them all for a NodeList, the above line is useful.

Labels:


posted by ruffin at 1/11/2012 11:29:00 AM
0 comments


All posts can be accessed here:


Support freedom
Last year o' posts:



Powered by Blogger furthurnet.org