Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript this inside arrow function

function A() {
  this.val = "Error";
  (function() {
    this.val = "Success";
  })();
}

function B() {
  this.val = "Error";
  (() => {
    this.val = "Success";
  })();
}

var a = new A();
var b = new B();
a.val // "Error"
b.val // "Success"
Source by developer.mozilla.org #
 
PREVIOUS NEXT
Tagged: #javascript #arrow #function
ADD COMMENT
Topic
Name
8+2 =