May 2016 JaxNode
Let and Const
Iterators and Generators
Arrow => functions
Reflection
New literals
Template Strings
Classes
Lexical Scoping
Maps, Set, WeakMap
ArrayBuffer
Promises
Octal support
var ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_';
let random_base64 = function random_base64(length) {
var str = "";
for (var i=0; i < length; ++i) {
var rand = Math.floor(Math.random() * ALPHABET.length);
str += ALPHABET.substring(rand, rand+1);
}
return str;
}
function add(a, b = 0) {
return a + b;
}
console.log(add(4)); // results 4
const myAnimals = ['dog', 'cat', 'platipus'];
function listAnimalsES2015(...animals) {
animals.forEach(function(animal) {
console.log(animal);
});
}
listAnimalsES2015(myAnimals);
// returns
// dog
// cat
// platipus
var parts = ['shoulders', 'knees'];
var lyrics = ['head', ...parts, 'and', 'toes'];
// ["head", "shoulders", "knees", "and", "toes"]
var foo = ["one", "two", "three"];
var [one, two, three] = foo;
console.log(one); // "one"
console.log(two); // "two"
console.log(three); // "three"
const elGatos = ['stan', 'tom', 'bebe', 'alf'];
const [cat1, cat2, ...restOfGatos] = elGatos;
console.log(cat1); // "one"
console.log(cat2); // "two"
console.log(restOfGatos); // "three"
function Foo() {
if (!new.target) throw "Foo() must be called with new";
console.log("Foo instantiated with new");
}
Foo(); // throws "Foo() must be called with new"
new Foo(); // logs "Foo instantiated with new"
var O = {a: 1};
Object.defineProperty(O, 'b', {value: 2});
O[Symbol('c')] = 3;
Reflect.ownKeys(O); // ['a', 'b', Symbol(c)]
function C(a, b){
this.c = a + b;
}
var instance = Reflect.construct(C, [20, 22]);
instance.c; // 42
var handler = {
get: function(target, name){
return name in target?
target[name] :
37;
}
};
var p = new Proxy({}, handler);
p.a = 1;
p.b = undefined;
console.log(p.a, p.b); // 1, undefined
console.log('c' in p, p.c); // false, 37
var sym1 = Symbol();
var sym2 = Symbol("foo");
var sym3 = Symbol("foo");
Symbol("foo") === Symbol("foo"); // false
var obj = {};
obj[Symbol("a")] = "a";
obj[Symbol.for("b")] = "b";
obj["c"] = "c";
obj.d = "d";
for (var i in obj) {
console.log(i); // logs "c" and "d"
}
FROM node:6.1.0
RUN mkdir /src
COPY package.json /src
WORKDIR /src
RUN npm install
ENV foo bar
# Add your source files
COPY . /src
CMD ["npm","start"]
bash > docker build -t username/container:version /src
bash > docker run -d -p 80:3000 username/container:version