What's the most well written javascript you've ever seen?
for me, its the d3 source code. All the design decisions are deeply thought out, resulting in a powerful declarative syntax thats easy to use, yet still scales to the most complex applications. I am devoting the next few years of my life to its study.
I like this code to loop through an array and do something with each element:
var arr = [1,2,3];
for (var i in arr) {
// make sure the property is actually in the array object and not its prototype
if (arr.hasOwnProperty(i)) {
// now i contains the index of the current element, not the element itself
var x = arr[i];
// now we can do something with the element
console.log(x);
}
}
Javascript is such a beautiful and well-designed language.