Académique Documents
Professionnel Documents
Culture Documents
JavaScript is a stripped down version of Java JavaScript does not exist outside browsers JavaScript is inconsistent and buggy JavaScript is not object-orientated
Birth of Mocha, then rename to LiveScript Netscape and Sun collaboration for Java in browsers; LiveScript gets renamed to JavaScript IE team reverse engineers JavaScript to JScript Browser war begins Standardization of JavaScript at ECMA; ECMAScript becomes the official name Rise of Ajax JavaScript libraries emerge ECMAScript 5
Semicolon insertion typeof and instanceof with and eval == and != new
Self
prototypal inheritance dynamic objects
Java
syntax conventions
Scheme
lambda loose typing
Perl
regular expressions
Null Undefined
(a + b) + c === a + (b + c) Produces false for some values of a, b, c. Integers under 9007199254740992 (9 quadrillion) are ok.
9007199254740992 === 9007199254740992 + 1
Special number: Not a Number Result of undefined or erroneous operations Toxic: any arithmetic operation with NaN as an input will have NaN as a result NaN is not equal to anything, including NaN NaN === NaN is false NaN !== NaN is true
A sequence of 0 or more 16-bit Unicode characters No separate character type Characters are represented as strings with length of 1 Strings are immutable Similar strings are equal ( === ) String literals can use single or double quotes with \
> "hello".charAt(0) h > "hello, world".replace("hello", "goodbye") goodbye, world > "hello".toUpperCase() HELLO
Boolean type: true or false Everything else is truthy or falsy 0, "", NaN, null and undefined are falsy
Everything else is truthy
var obj = new Object(); Or var obj = {}; These are semantically equivalent; the second is called object literal syntax and is more convenient.
obj.name = "My Name" var name = obj.name; Or obj["name"] = "My Name"; var name = obj["name"]; Semantically equivalent; the second uses strings so can be decided at run-time (and can be used for reserved words)
var obj = { name: "Carrot", "for": "Max", details: { color: "orange", size: 12 } } > obj.details.color Orange > obj["details"]["size"] 12