TypeScript: Lambdas and using 'this' -


javascript frameworks call callbacks using apply().

typescript's arrow notation, however, doesn't seem allow me access 'this' pointer.

how's done?

if isn't, there place down-vote current 'this' handling on lambdas?

typescript's handling of this in arrow functions in line es6 (read: arrow functions). due specification, inconsistent act other way.

if want access this of current function, can use regular function.

for example, change:

function myscope() {     var f = () => console.log(this); // |this| instance of myscope     f.call({}); }  new myscope(); 

to:

function myscope() {     var f = function() { console.log(this); } // |this| {}     f.call({}); }  new myscope(); 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -