[go: up one dir, main page]

0% found this document useful (0 votes)
71 views1 page

ES6 in A Nutshell

Arrow functions were introduced in ES6 as a more concise way to write functions, similar to lambda functions in Python. Some key differences between old JavaScript and ES6 include let and const block scoping variables, object destructuring for accessing multiple object properties, default parameters, and arrow functions handling this bindings better than the old function syntax.

Uploaded by

truth sayer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
71 views1 page

ES6 in A Nutshell

Arrow functions were introduced in ES6 as a more concise way to write functions, similar to lambda functions in Python. Some key differences between old JavaScript and ES6 include let and const block scoping variables, object destructuring for accessing multiple object properties, default parameters, and arrow functions handling this bindings better than the old function syntax.

Uploaded by

truth sayer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Arrow functions

Old JS ES6
var let and const
Can re-define variables: Cannot red-fine with let:
var x = 1; let x = 1;
var x = 2; let x = 2;
No errors produced on compile. Would produce errors on compile.

But can re-assign values: Can re-assign values:


x = 5; x = 5;
Global and function scope Global, function and block scopes {}
Concatenation with plus Concatenation with variables inside just like in
Python
Strings with double quote Strings with back-ticks
Object Literals need to repeat key and values in Object Literals don’t need to repeat keys and
dictionaries values if they are they are the same.
Object deconstruction: need to follow. dot Can get multiple items back from object using
notation to get object items dictionary notation.
No Arrow functions Arrow functions (they are equivalent of the
This notation within functions has issues when lambda function in python)
more than one level of drill down is seen. Arrow functions allow using this even with
multi-level drill-down
Setting default parameters in functions is a pain Can set default parameters in functions just like
in other programming languages.
For each and Map methods for lists

You might also like