Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

normal function vs arrow function in javascript

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

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

javascript function declaration vs arrow function

Regular functions created through function declarations / expressions are both constructible and callable. ... Arrow functions (and methods) are only callable i.e arrow functions can never be used as constructor functions. Hence, they can never be invoked with the new keyword.
Comment

arrow function vs function in javascript

// Arrow function vs function
// Function in JavaScript
function regular(){
  console.log("regular function");
}
regular(); //regular function

// Arrow Function
const arrow = () => console.log("Arrow function");
arrow(); //Arrow function
Comment

js arrow vs normal function

// jsdrops.com/arrow-functions

this.whoIsThis = 'TOP'; // Identify this scope

// 1) Defining
const fancyObj {
  whoIsThis: 'FANCY', // Identify this object
  regularF: function () {
    console.log('regularF', this.whoIsThis);
  },
  arrowF: () => {
    console.log('arrowF', this.whoIsThis);
  },
};

// 2) Calling
console.log('TOP-LEVEL', this.whoIsThis); // It's "TOP" here

fancyObj.regularF(); // Output #1 (Fancy)
fancyObj.arrowF();   // Output #2 (Top)

fancyObj.regularF.call({whoIsThis: 'FAKE'}); // Output #3 (Fake)
fancyObj.arrowF.call({whoIsThis: 'FAKE'});   // Output #4 (Top)
Comment

js arrow function vs function

// currently common pattern
var that = this;
getData(function(data) {
  that.data = data;
});

// better alternative with arrow functions
getData(data => {
  this.data = data;
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: how to download array of files from aws s3 using aws sdk in nodejs 
Javascript :: conver all array to object 
Javascript :: ReferenceError: document is not defined 
Javascript :: + javascript 
Javascript :: var = {} js 
Javascript :: best method to convert string to upper case manually 
Javascript :: javascript problems 
Javascript :: inertia js 
Javascript :: how to link js function to button 
Javascript :: how to pass functions as a props in react js 
Javascript :: angular js 
Javascript :: how to check if an element already exists in an array in javascript 
Javascript :: react variable component 
Javascript :: Angular 4 "Property does not exist on type component" 
Javascript :: understanding currying 
Javascript :: lettre au hasard javascript 
Javascript :: npm ERR! missing script: build:dev 
Javascript :: javascript null 
Javascript :: /function 
Javascript :: array of objects in javascript 
Javascript :: excel json to table 
Javascript :: jquery function called onDeleteMovie. This function should be invoked upon clicking the Delete button of each one of the movie templates 
Javascript :: jmathplot 
Javascript :: html check template browser 
Javascript :: discord js get specific user from users 
Javascript :: making all makers to show in react native map 
Javascript :: object for loop 
Javascript :: “new Set” is returning an empty set in nodejs 
Javascript :: how to check expo package compatibility 
Javascript :: open bytes in new tab angular 
ADD CONTENT
Topic
Content
Source link
Name
1+5 =