O'Reilly logo

Dart: Scalable Application Development by Ivo Balbaert, Sergey Akopkokhyants, Davy Mitchell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

JsFunction and the this keyword

The this keyword refers to the current instance of a class in Dart and never changes once the class object is instantiated. Generally, we should omit the this keyword and use it only if we have name conflicts between the class members and function arguments or variables. In JavaScript, the this keyword refers to the object that owns the function and behaves differently compared to Dart. It mostly depends on how a function is called. We can't change the value of this during function execution and it can be different every time the function is called. The call and apply methods of Function.prototype were introduced in ECMAScript 3 to bind any particular object on the value of this in the call of these methods:

fun.call(thisArg[, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required