function bakeTheCake(flour, sugar, ...other) {
assert(Array.isArray(other));
}
var dateFields = [2013, 12, 24];
var myDate = new Date(...dateFields);
var evenMoreSpecificDate = [...dateFields, 18, 20];
var [firstName, lastName] = person.getName();
var [first, ...allButFirst] = document.querySelectorAll("section");
function runTests({ reporter, ui }) {}
runTest({ reporter: "dot", ui: "tdd"})
var re = /([a-z]+)(\s)(.*)([^a-z])/;
var [, hello, space, world, bang] = re.exec("hello world!");
var myFunc = function (size) {
size = size || 'XXL';
};
var myFunc = function (size = 'XXL') {
// thusly
};
var name = 'Han',
var whenShot = 'first';
var addressTmpl = `There is proof that ${name} shot ${whenShot}`;
var multiline = `${name} Solo is confronted by the
bounty hunter Greedo at the Mos Eisley Cantina.
The initial change was made to the 1997
Star Wars Trilogy Special Edition re-release.`;
function printAwesomeMovies(url) {
getMovies(url, (xhr, movies) => {
movies.filter(m => m.genre === 'Adventure')
.map(m => { title: m.title })
.each(m => console.log(m));
};
}
function* naturalNumbers() {
let current = 0;
while (true) {
yield current++;
}
}
let seq = naturalNumbers();
assert(seq.next() === 0);
assert(seq.next() === 1);
assert(seq.next() === 2);
spawn(function*() {
var data = yield $.ajax(url);
$('#result').html(data);
var status = $('#status').html('Download complete.');
yield status.fadeIn().promise();
yield sleep(2000);
status.fadeOut();
});
Every time the task yields a promise,
var actor = { name: 'Harrison Ford', salary: 0 };
var interceptor = {
set: function (receiver, property, value) {
console.log(property, 'is changed to', value);
receiver[property] = value;
}
};
actor = Proxy(actor, interceptor);
get, has, keys, deleteProperty…
let
)for…of
const
Object.mixin()
Map()
and Set()
--harmony