On Github maxwellito / es6-quiz-slides
WARNING This quiz is subject to dirty tricks.Do not trust the speaker.But don't be scared to answer.
What's the output?
const KEY = 'white_rabbit'; if (true) { const KEY = 'ginger_rabbit'; } console.log(KEY);
What's the output?
let x = 42; if (true) { let x = 1337; } console.log(x);
What's the output?
let x = 42; if (true) { console.log(x); let x = 1337; }
// Here is a new way to define functions var double = i => i*2; // Which is like var double = function (i) { return i * 2; };
How to use the new syntax to define a function which doesn't take any parameter?
What's the output?
var x = `foo ${y}`, y = `bar ${x}`; console.log(x);
What's the output?
var x = `foo ${y}`, y = `bar ${x}`; console.log(y);
var myMap = new Map(), keyObj = {}, keyFunc = function () {}; myMap.set(keyObj, "value for keyObj"); myMap.set(keyFunc, "value for keyFunc"); myMap.get(keyObj); // "value for keyObj" myMap.get(keyFunc); // "value for keyFunc"
var mySet = new Set(); mySet.add(5); mySet.add("something"); mySet.has(5); // true mySet.has("some" + "thing"); // true mySet.has(32); // false
What's the attribute to get the quantity of objects stored in a `Set` object?
What's the difference between Map/Set and WeakMap/WeakSet ?
In ES6, is there a better way to create this object?
let options = { protocol: protocol, url: url, method: method, callback: callback };
let options = { protocol, url, method, callback };
Which keyword is not allowed in ES6 Class definition?
// Create a logger facade class Logger { constructor (type = "Info") { this.type = type; } get current() { return `Logger: ${this.type}`; } set current(type) { this.type = type; } static create(type) { return new this(type); } log (message) { /* Basic method */ } }
var score = [12, 7, 14]; Math.max(...score);
function stuff(x::Number, y::String) { // Do stuff.. }
function stuff(x, ...y) { // Do stuff.. }
function stuff(x, y=12) { // Do stuff.. } stuff(2);
function stuff(x, y=x/3) { // Do stuff.. } stuff(6);
var {foo, bar} = { foo: 'FOO', bar: 'BAR' };
var [first, , last] = [1,2,3];
function stuff(a, x=12, y=42) { // Do stuff.. } stuff(1, ,2);
What does the Promise constructor take as parameter(s)?
How to use the progress on a ES6 Promise?(like in the Q library)
uploadFile() .then(function (data) {/* Success */}, function (err) {/* Error */}, function (progress) {/* Progress */}); // Or.. uploadFile() .progress(function (progress) { // Progress });
Is there a method to take a lot of promises, wrap them into one which will be resolved (or rejected) once one of them will be resolved?
Promise .race([loadSiteMap, loadGOTin4K]) .then(function(value) { // Success case }, function(reason) { // Error case });
Which one of this keywords won't be compatible on ES6?
Which stable browser got the best ES6 support ?
Which var got the max value?
var a = 0x1101010110111, b = 0o1101010110111, c = 0b1101010110111, d = 001101010110111, e = 0E1101010110111, f = 1101010110111;