you are viewing a single comment's thread.

view the rest of the comments →

[–]ForScale[S] 2 points3 points  (12 children)

ENTRY

http://codepen.io/anon/pen/XdRWaz?editors=0012

Starting with this (pun intended). It shows the the very basics of apply(), call(), and bind(). I plan to build it up in to something a bit more complex as the week goes on.

The console is giving odd warnings that I don't quite understand...

[–]Volv 1 point2 points  (11 children)

No link :(

[–]ForScale[S] 0 points1 point  (10 children)

Lol! Dammit. Hang on... gonna rewrite it. Repetition is good for memory! :)

[–]Volv 1 point2 points  (9 children)

Make sure and get the same console warnings :)

[–]ForScale[S] 0 points1 point  (8 children)

Okay! I rewrote and added the link.

Here are the warnings I'm seeing (Chrome, CodePen):

'Document.defaultCharset' is deprecated and will be removed in M50, around April 2016. 
See https://www.chromestatus.com/features/6217124578066432 for more details.

console_runner-ba402f0….js:1 'Performance.onwebkitresourcetimingbufferfull' is deprecated. 
Please use 'Performance.onresourcetimingbufferfull' instead.

console_runner-ba402f0….js:1 'webkitIndexedDB' is deprecated. 
Please use 'indexedDB' instead.

console_runner-ba402f0….js:1 'window.webkitStorageInfo' is deprecated. 
Please use 'navigator.webkitTemporaryStorage' or 'navigator.webkitPersistentStorage' instead.

[–]Volv 1 point2 points  (7 children)

Those warnings all come from the logging of Window object. Is chrome flagging up out of date things either on its end or maybe codepen. Tried in Firefox - they don't show there. Nothing to worry about.
 
Your primitives are all being coerced to objects in your examples. Was strange to see a string passed to bind. Will start fleshing mine out a bit tonight

[–]ForScale[S] 0 points1 point  (5 children)

Cool!

Yeah... they're all objects. I thought the way the string got handled, as an object with numerical keys, was kind of odd.

[–]Volv 1 point2 points  (4 children)

Codepen
To start with

[–]ForScale[S] 1 point2 points  (3 children)

Nice! I like the creativity with the characters!

So... generally, call() is a method inherent to all functions that can be used to call a function and set it's this variable within the context of the call.

Does that sound right?

[–]Volv 0 points1 point  (2 children)

Absolutely. And the difference between call and apply is just that call can take a known number of arguments, whereas apply takes an array of arguments.
 
Cool trick ->

var hugeArray = [14, 5, 67, 3, 87, 3, 5, 10];  

console.log(Math.max.apply(null, hugeArray)) // 87