June 15

Javascript Enlightenment Review

javascript enlightenment

This book is a good read for understanding javascript coding syntax, prototyping, scope, and closure.   Although brief and repetitive after Chapter 8, it clarifies several aspects of the language.  If you’re an intermediate to advance javascript developer, this book many not be useful to you.  The most important thing is javascript’s flexibility.  You only use primitives and objects; javascript uses wrappers automatically when needed.  The other parts are comparing, contrasting methods, instantiation, closure, scope, hoisting.  The author describes what matters is the way properties are accessed, mainly if using reserved keywords such as “class”.

The problem with NULLS (see example below):

[code]var myNull = null;
console.log(typeof myNull); // outputs ‘object’ NOT null[/code]

// Use === when comparing null or undefined, because == will not work.

[code]Foo.prototype.x = 1;
var FooInstance = new Foo();
console.log(FooInstance.x); // outputs 1
// now let’s replace/override the prototype object with a new Object() object
Foo.prototype = {x:2};
console.log(FooInstance.x) // outputs 1 not 2[/code]

Continue reading

Category: Code, Review | LEAVE A COMMENT