Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

why to use arrow functions over normal function

// => why to choose arrow function over normal function 
1. short syntax, good as callback functions
 ([].map(() => {}) is better than [].map(function () {}))

2. when using class component, with arrow functions no need to bind this

// example: 

 -// this will be undefined
		button.addEventListener('click', () => {console.log(this); })
  // this will refer to dom button
		button.addEventListener('click', function () {console.log(this); }) 
Comment

PREVIOUS NEXT
Code Example
Javascript :: vanilla document.ready function 
Javascript :: reactstrap search bar 
Javascript :: js create nested object from fields 
Javascript :: events in javascript 
Javascript :: multiple elements with same id jquery 
Javascript :: react native asyncstorage getItem example 
Javascript :: javascript constructor 
Javascript :: concat keys json 
Javascript :: javascript addeventlistener pass parameters 
Javascript :: js what does var mean 
Javascript :: typescript jsdoc interface 
Javascript :: js date option 
Javascript :: javascript switch items in array 
Javascript :: html call javascript function with input value 
Javascript :: synchronized function javascript 
Javascript :: jquery with svelte 
Javascript :: progress bar loading ajax 
Javascript :: js some 
Javascript :: superagent vs axios 
Javascript :: how to parse header in node.js lambda 
Javascript :: error: Unknown dialect undefined 
Javascript :: adding parameters to url react router 
Javascript :: big o theory 
Javascript :: jq not contains 
Javascript :: react text to link 
Javascript :: javascript get all instances of a class 
Javascript :: Format javascript date with date.js library 
Javascript :: sequelize attributes exclude all 
Javascript :: take one character in end of string javascript 
Javascript :: width and height with node js 
ADD CONTENT
Topic
Content
Source link
Name
7+9 =