es6katas.org Kata #6: arrow functions - binding

tome

I am learning ECMAScript6 in es6katas.org, which is great and highly recommended. I am currently stuck at this pretty basic kata about arrow function. I can't seem to understand what the author meant in the second test:

class LexicallyBound {

    getFunction() {
        return () => {
              return new LexicallyBound();
        }
    }

    getArgumentsFunction() {
        return function() {return arguments}
    }

}

it('bound at definition time, use `=>` ', function() {
    var bound = new LexicallyBound();
    var fn = bound.getFunction();

    assert.strictEqual(fn(), bound);
});

Can someone assist in figuring it out?

Sheepy

I think it wanted you to change getFunction to return this.

Reason: Fat arrow function's this is bounded to the defining context (the bound object) when it was defined - when bound was created - instead of having a dynamic this like normal functions.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to use ES6 arrow functions with promise binding (bluebird)

From Dev

ECMAScript 6 arrow functions

From Dev

ES6 arrow functions

From Dev

es6 arrow functions debugger statement

From Dev

Are ES6 arrow functions incompatible with Angular?

From Dev

ES6 arrow functions not working on the prototype?

From Dev

javascript es6 double arrow functions

From Dev

Argument types in functions versus in arrow functions in ES6

From Dev

ECMA Script 6 Arrow functions as object properties

From Java

Methods in ES6 objects: using arrow functions

From Java

Is it possible to export Arrow functions in ES6/7?

From Java

Using _ (underscore) variable with arrow functions in ES6/Typescript

From Dev

Immediate function using JavaScript ES6 arrow functions

From Java

When should I use `return` in es6 Arrow Functions?

From Dev

How to run ES6 code with arrow functions in Safari?

From Dev

What does "this" refer to in arrow functions in ES6?

From Dev

Official information on `arguments` in ES6 Arrow functions?

From Dev

Explain effect of ES6 class constructor and arrow functions

From Dev

jQuery .each() function with ES6 arrow functions

From Dev

Jump to ES6 arrow functions in Sublime text editor

From Dev

Can't use fat arrow functions (ES6) in react

From Dev

This not working as expected in nested arrow functions in ES6

From Dev

React / ES6 - Why calling a function inside another only works with es6 arrow functions?

From Dev

Compiling ES6 arrow functions to Es5 using Babel.js

From Dev

ES6 if in arrow function

From Dev

ES 6 Arrow Function challenge

From Dev

When should I use a return statement in ES6 arrow functions

From Dev

ES6 in NodeJS: Arrow functions in object literal, what is the returned 'this' value?

From Dev

Why we have to wrap throw with brackets in es6 arrow functions

Related Related

  1. 1

    How to use ES6 arrow functions with promise binding (bluebird)

  2. 2

    ECMAScript 6 arrow functions

  3. 3

    ES6 arrow functions

  4. 4

    es6 arrow functions debugger statement

  5. 5

    Are ES6 arrow functions incompatible with Angular?

  6. 6

    ES6 arrow functions not working on the prototype?

  7. 7

    javascript es6 double arrow functions

  8. 8

    Argument types in functions versus in arrow functions in ES6

  9. 9

    ECMA Script 6 Arrow functions as object properties

  10. 10

    Methods in ES6 objects: using arrow functions

  11. 11

    Is it possible to export Arrow functions in ES6/7?

  12. 12

    Using _ (underscore) variable with arrow functions in ES6/Typescript

  13. 13

    Immediate function using JavaScript ES6 arrow functions

  14. 14

    When should I use `return` in es6 Arrow Functions?

  15. 15

    How to run ES6 code with arrow functions in Safari?

  16. 16

    What does "this" refer to in arrow functions in ES6?

  17. 17

    Official information on `arguments` in ES6 Arrow functions?

  18. 18

    Explain effect of ES6 class constructor and arrow functions

  19. 19

    jQuery .each() function with ES6 arrow functions

  20. 20

    Jump to ES6 arrow functions in Sublime text editor

  21. 21

    Can't use fat arrow functions (ES6) in react

  22. 22

    This not working as expected in nested arrow functions in ES6

  23. 23

    React / ES6 - Why calling a function inside another only works with es6 arrow functions?

  24. 24

    Compiling ES6 arrow functions to Es5 using Babel.js

  25. 25

    ES6 if in arrow function

  26. 26

    ES 6 Arrow Function challenge

  27. 27

    When should I use a return statement in ES6 arrow functions

  28. 28

    ES6 in NodeJS: Arrow functions in object literal, what is the returned 'this' value?

  29. 29

    Why we have to wrap throw with brackets in es6 arrow functions

HotTag

Archive