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 :: html form data to json 
Javascript :: js play sound 
Javascript :: combine 2 "arrays with objects" and remove object duplicates javascript 
Javascript :: Using json_encode() function to convert an Array to a string 
Javascript :: upload image postman 
Javascript :: enforcefocus select2 modal 
Javascript :: run for loop every second js 
Javascript :: classlist remove multiple classes 
Javascript :: setup react app from cpanel 
Javascript :: vue implode array 
Javascript :: window.location.origin 
Javascript :: javascript single thread 
Javascript :: Check propery of an objects array 
Javascript :: new line in javascript string 
Javascript :: javascript on screen width change 
Javascript :: difference between react and react native 
Javascript :: Using flat() method 
Javascript :: react usememo 
Javascript :: get textarea value jquery 
Javascript :: how to print something in javascript 
Javascript :: headers with fetch 
Javascript :: let and var difference 
Javascript :: vue nested loop 
Javascript :: date range query knex 
Javascript :: javascript check if length is greater than 0 
Javascript :: ckeditor inline editor example 
Javascript :: nested include sequelize 
Javascript :: Upload different files in different folders using Multer in NodeJs 
Javascript :: arithmetic operators in javascript 
Javascript :: substr javascript 
ADD CONTENT
Topic
Content
Source link
Name
1+6 =