Search
 
SCRIPT & CODE EXAMPLE
 

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()
Comment

normal function vs arrow function

// Normal Function
let add = function (num1, num2) {
return num1 + num2;
}

// Arrow Function
let add = (num1, num2) => num1 + num2;
Comment

PREVIOUS NEXT
Code Example
Javascript :: yup oneof 
Javascript :: js backwards loop 
Javascript :: how to assign char in a string javascript 
Javascript :: fake delay in fetch 
Javascript :: getinitialprops to a hoc in next js 
Javascript :: check when input number value goes up or down 
Javascript :: crear etiquetas html con javascript 
Javascript :: node mongodb $or 
Javascript :: onclick automatically called after 10 seconds 
Javascript :: sequelize check if exists 
Javascript :: html js display pdf file 
Javascript :: fetch is not defined jest react 
Javascript :: mongodb find array with element 
Javascript :: stimulus params 
Javascript :: video recorder using webrtc and javascript 
Javascript :: postDataToFirebase 
Javascript :: reactjs wait for image to load from url 
Javascript :: javascript prototype example 
Javascript :: django csrf failed ajax 
Javascript :: jquery if today is friday 
Javascript :: javascript switch syntax 
Javascript :: bogo sort js 
Javascript :: json schema eg 
Javascript :: full form of json 
Javascript :: associative multidimensional array javascript 
Javascript :: js deep copy 
Javascript :: vue slice words 
Javascript :: how to create an async function from a string in node js 
Javascript :: compare if strings are equal javascript 
Javascript :: change node bash root 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =