Message from JavaScript discussions

November 2018

β€” Aka normal scoping

β€” 

var test = function() {
this.a = function() {
return this;
};
this.b = (() => this);
};
var a = new test();
var b = a.b;

if (a.b() === b()) {
console.log('It is bound');
}

β€” No...

β€” Run it🀀

β€” You're testing the same function against itself

β€” You never run a

β€” It behaves like a function that is bound to the parent this, but it's not bound

β€” Because it doesn't have its own context

β€” a is normal, and we talk about arrow function test

β€” 

var test = function() {
this.a = (function(me) {
return function() {
return me;
}
})(this);;
this.b = (() => this);
};

var test = new test();
var a = test.a;
var b = test.b;

if (test.a() === b() && test.b() === a() && a() === b()) {
console.log('It is bound!!!!!!!!!!!');
}

Message permanent page

β€” Language:

js


Source:
var test = function() {
this.a = (function(me) {
return function() {
return me;
}
})(this);;
this.b = (() => this);
};

var test = new test();
var a = test.a;
var b = test.b;

if (test.a() === b() && test.b() ===


Errors:
source_file.js:15
});
^

SyntaxError: Unexpected token }
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:374:25)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Function.Module.runMain (module.js:442:10)
at startup (node.js:136:18)
at node.js:966:3

Message permanent page

β€” πŸ€£