Find your content:

Search form

You are here

Where you should not use Arrow functions? - Javascript Interview Questions - HelpInterview

 
Share

1. If need to use arguments in your function then do not write as arrow function because it wont support arguments property.

2. Extending the object method through prototype then do not write new method in arrow function because this always refers in global instead of the class object.

Article.prototype.truncate = function(length) {
this.content = this.content.substring(0, length);//it works, regular function
}

 

Article.prototype.truncate =(length) => {

this.content = this.content.substring(0, length);//it won't work, this refers global

}

My Block Status

My Block Content