I am currently in the process of re-learning JavaScript from scratch. And I found the light:<p>1. Douglas Crockford videos: <a href="http://www.yuiblog.com/crockford/" rel="nofollow">http://www.yuiblog.com/crockford/</a><p>2. Eloquent JavaScript intermediate level tutorials: <a href="http://eloquentjavascript.net/contents.html" rel="nofollow">http://eloquentjavascript.net/contents.html</a>
The "even nicer [array for loop] idiom" is pretty cool:<p><pre><code> for (var key = 0, value; value = someArray[key++];) {
// value is already defined by for loop
console.log('index: ' + key, 'value: ' + value);
}
</code></pre>
Also, I finally understand closures:<p>"Whenever JavaScript executes a function, a 'scope' object is created to hold the local variables created within that function. It is initialised with any variables passed in as function parameters. This is similar to the global object that all global variables and functions live in, but with a couple of important differences: firstly, a brand new scope object is created every time a function starts executing, and secondly, unlike the global object (which in browsers is accessible as window) these scope objects cannot be directly accessed from your JavaScript code... A closure is the combination of a function and the scope object in which it was created."
Since I started using JS heavily lately, it's nice to be reminded of some things. Thanks for posting.<p>One question though, it says:<p><pre><code> If you want to append an item to an array, the safest way to do it is like this:
a[a.length] = item; // same as a.push(item);
</code></pre>
a.push() variant seems more elegant to me. Why is a[] variant "safer"?
Off-topic, but I must say that this site handles resizing very well. I really appreciate it when a website seamlessly transitions from desktop-size to mobile-size layout. Sometimes I just like having my browser window shrunk down (or zoomed in for viewing from farther away), which means that with most sites I have to scroll horizontally, which is not very usable.
It is probably a good idea to add 2006 to the title since that's the date of the last update [1].<p>1. <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/A_re-introduction_to_JavaScript#Original_Document_Information" rel="nofollow">https://developer.mozilla.org/en-US/docs/Web/JavaScript/A_re...</a>
still a better introduction to javascript:<p><a href="https://www.destroyallsoftware.com/talks/wat" rel="nofollow">https://www.destroyallsoftware.com/talks/wat</a><p>(with a little bit of ruby)
"We've introduced another keyword: 'new'. new is strongly related to 'this'. What it does is it creates a brand new empty object, and then calls the function specified, with 'this' set to that new object"<p>Perhaps it would be worth to mention that 'new' not only sets 'this' to be the empty object but also return that object to the location where new was used.
I've read this article a couple of times in the last few years and it never ceases to amaze me. Clearly and in a concise way it lists all the points that people usually miss about JS.
"if you're used to math in C or Java. Watch out for stuff like:
0.1 + 0.2 == 0.30000000000000004"<p>Uh, how floating poing operators are different than this in C or java
One of my favorite tutorials from John Resig: <a href="http://ejohn.org/apps/learn/" rel="nofollow">http://ejohn.org/apps/learn/</a>
If you wanted to find a friend for someone would you keep trying to introduce them to same stupid ugly person, while saying: "Look! He/she is wearing make-up this time!".