On Github pfac / cesium-intro.js
Refurbished
// Boolean true == false // Number + number = Number 1 + 1.0 // String + string = String "Pedro Costa" // Object + Object = NaN { nome: "Pedro", apelido: "Costa" } // Function + function = String function fullName(firstName, secondName) { return firstName + secondName }
// Global name = "Pedro" + " " + "Costa" // Global var age = 24; function f() { // Scoped var job = { degree: "Software Engineer" } }
f = function(){} // Each function has a prototype f.prototype.add = function(x,y){ return x+y; } // Constructors === functions a = new f() // {} // Objects inherit from the constructor prototype a.add(1,2) // 3
// Object is the at the top of the chain Object.prototype.mult = function(x,y){ return x*y; } // All objects inherit from Object.prototype a.mult(2,3) // 6 // Object.create automatically changes the prototype g = function(){}; g.prototype = Object.create(f.prototype) // g.prototype --> f.prototype // --> Function.prototype --> Object.prototype b = new g(); b.add(5,5) // 10 b.mult(5,5) // 25
Disclaimer: from my experience
Seriously, EVERYTHING
Jasmine, QUnit, Mocha...whatever floats your boat
{} and []new Object and new Array
Fuck IE...
Or Graceful Degradationjust do something about it