Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

difference between normal function and arrow function

//* main difference is arrow functions do not have their own this
let user = {
  name: "HEllo world",
  functTest() {
    console.log("----functTest---", this.name) // HEllo world
  },
  arrowTest: () => { 
    console.log("----arrowTest----", this.name) // undefined
  }
}
user.functTest()
user.arrowTest()
 
PREVIOUS NEXT
Tagged: #difference #normal #function #arrow #function
ADD COMMENT
Topic
Name
8+1 =