Skip to content Skip to sidebar Skip to footer

Use Arrow Functions In Jquery Plugin

I am writing a jQuery plugin. But it doesn't seem to work when I use arrow function to extend jQuery. This works : $.fn.extend({ func: function (params) { var ob = $(th

Solution 1:

It's because different rules apply to arrow functions when it comes to binding this.

An arrow function expression has a shorter syntax than a function expression and does not bind its own this, arguments, super, or new.target.

See this article for more information.

Post a Comment for "Use Arrow Functions In Jquery Plugin"