Created
July 2, 2015 23:28
-
-
Save hackjoy/02e558ffe7a638a48c22 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Interpolate variable bindings | |
var name = "Bob", time = "today"; | |
`Hello ${name}, how are you ${time}?` | |
// Arrows | |
// e => {} | |
// function(e){} | |
// Expression bodies | |
var odds = evens.map(v => v + 1); | |
var nums = evens.map((v, i) => v + i); | |
// Statement bodies | |
nums.forEach(v => { | |
if (v % 5 === 0) | |
fives.push(v); | |
}); | |
// Lexical this, uses outer scope | |
var bob = { | |
_name: "Bob", | |
_friends: [], | |
printFriends() { | |
this._friends.forEach(f => | |
console.log(this._name + " knows " + f)); | |
} | |
} | |
// Classes | |
class SkinnedMesh extends THREE.Mesh { | |
constructor(geometry, materials) { | |
super(geometry, materials); | |
this.idMatrix = SkinnedMesh.defaultMatrix(); | |
this.bones = []; | |
this.boneMatrices = []; | |
} | |
update(camera) { | |
super.update(); | |
} | |
static defaultMatrix() { | |
return new THREE.Matrix4(); | |
} | |
} | |
// Let is the new var, const is single assignment | |
function f() { | |
{ | |
let x; | |
{ | |
// okay, block scoped name | |
const x = "sneaky"; | |
// error, const | |
x = "foo"; | |
} | |
// error, already declared in block | |
let x = "inner"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment