ES6 Basic

  • 1/20

    Constants are block-scoped variables.

    Next >
  • 2/20

    The statement "var" declares a block-scoped variable.

    Next >
  • 3/20

    The statement "let" declares a block scope local variable.

    Next >
  • 4/20

    What is the final value of "obj" in the following example?

    const obj = { foo: 1 }; obj.bar = 2
    Next >
  • 5/20

    What will be the result of the following?

    const speed = 'quick'; `The ${speed} brown fox jumps over the lazy dog.`
    Next >
  • 6/20

    Rest is a new way for functions to handle an arbitrary number of parameters. Can you guess what the mysterious "a" variable holds?

    function mystery(...params) { return params; } let a = mystery(1,23,4);
    Next >
  • 7/20

    String interpolation is a much-needed new feature that is finally available in JavaScript. See an example below. Is there anything wrong with it?

    let name = 'Harry'; let occupation = 'wizard'; console.log(`Hi! My name is ${name}. I'm a ${occupation}.`);
    Next >
  • 8/20

    What value will return this expression?

    let x, { x: y = 1 } = { x }; y;
    Next >
  • 9/20

    What will return this function?

    (function() { let f = this ? class g { } : class h { }; return [ typeof f, typeof h ]; })();
    Next >
  • 10/20

    What's a Promise()?

    Next >
  • 11/20

    What value will return this expression ?

    [...[...'...']].length
    Next >
  • 12/20

    What will be the result of this expression?

    typeof (new (class F extends (String, Array) { })).substring
    Next >
  • 13/20

    What result will have this expression?

    typeof (function* f() { yield f })().next().next()
    Next >
  • 14/20

    Why is used super?

    Next >
  • 15/20

    ES6 introduces a special "const" declaration. Do you know what it does?

    const pi = 3.14; console.log(pi) //Prints 3.14
    Next >
  • 16/20

    ES6 gives us a number of new methods for operating with strings. Which one replaces this annoying piece of code?

    let some_text = "some string"; if(some_text.indexOf('str') !=-1{ return true; }
    Next >
  • 17/20

    Array.from() is a powerful method which converts array-like objects into real arrays. Why do we use it in the code below?

    let titleElements = document.querySelectorAll('.article .title') let titles = Array.from(titleElements).map( t => t.textContent ); console.log(titles);
    Next >
  • 18/20

    ES6 gives an alternative way to assign variables. Can you guess what the below code does?

    let a = 12, b = 3; [a, b] = [b, a];
    Next >
  • 19/20

    What is stored into the triangle array?

    var point = [1,3], segment = [point,[5,5]], triangle = [...segment,[1,8]];
    Next >
  • 20/20

    Is this a valid code?

    class Slave { // ... }; const slave = Slave();
    Next >
  • If You want to see your results leave Your e-mail (optional)