Wednesday, May 1, 2013

Javascript Facts



Javascript's native classes 
1. Array
2. Boolean
3. Date
4. Error
5. Function
6. Math is an object with static methods
7. Number
8. Object
9. RegExp
10. String

Any primitives of number, string or boolean used in an expression in javascript are primitives, not instances.  This example proves that strings are referenced by value:

var original = 'original';
undefined
var aCopy = original;
undefined
console.log(original + ' ' + aCopy);
original original
undefined
original = 'newness';
"newness"
console.log(original + ' ' + aCopy);
newness original


=== and !== type checked comparison operators
== and !=   automatic type coercion equality comparison operators