Javascript ES6

Javascript ES6


JavaScript ES6
 
In this tutorial, you will learn about ES6 with help of Examples:
  • More significant changes than ES5
  • Much new syntax
  • Very, Very high back compat 
  • ECMAScript 2015 is also known as ES6 and ECMAScript 6.
There are describes the most important features of ES6, are as follows:-
New Features in ES6
There are various new features in JavaScript:-
  • The let keyword
  • The const keyword
  • Arrow Functions
  • For/of
  • Map Objects
  • Set Objects
  • Classes
  • Promises
  • Symbol
  • Default Parameters
  • Function Rest Parameter
  • String.includes()
  • String.startsWith()
  • String.endsWith()
  • Array.from()
  • Array keys()
  • Array find()
  • Array findIndex()
  • New Math Methods
  • New Number Properties
  • New Number Methods
  • New Global Methods
  • Object entries
  • JavaScript Modules
JavaScript Let
  • Let is a block level variable.
  • Let you declare variables that are limited in scope to the block, statement, or expression.
  • Using var we can define a variable either globally, or locally to the entire function regardless of clock scope.
  • Let doesn’t allow duplicate variable creation.
Using let keyword in another example, ab, and c, are variables is as follows: 
 
Example -
 
https://lh4.googleusercontent.com/Hu55SAn-DRq6oSGK98Nmc97MtT4jO5HOkKnEcBST3NHO-VZ_tqVkErzP2M3x-uJs8JWtRNaIQespMWPZccBSd8uo97ykZgulL2_Djlrm5xPHIODXPQscjCpoYZPdoX-85-145A2z
 
Output
 
https://lh3.googleusercontent.com/zWFLAbay5IhHbwsjGiE408eL_yTdp6Gj-yz0URyU-mqh1hgQqCWZQnTEptfRLhURu-YUHRoGP3Fv0d6eGwQXOI0cJ2PW6AQEQjgqrUV9H1id7HTnljU_FxrflUFx2X2xwcUi5vDC
 
JavaScript Const
  • Constants are block level scope variables. The scope may be either global or local scope.
  • Constants are working like variables defined using let statements.
  • We can’t modify the value of constants.
  • Constant re-declarations are not allowed.
Using const keyword in another example, ab, and c, are variables is as follows:
If you want a general rule: always declare variables with const.
If you think the value of the variable can change, use let.
 
Example -
 
https://lh4.googleusercontent.com/5mcSR9wq_VOHzt-iLZ-oCiNJixTF1JDSUifa7j0f6elIHzPnVqlXFk1MQ09wOapLeznHCUjDuiC0K2-dA7l1dpj1CXvq4stV-jB-bLPUcxPnoJyPSJjVHwWzgZPC2jawJxkutnYp
 
Output -
 
https://lh6.googleusercontent.com/PJ2Ea3_OshEaU28MYUfyvaxRHzs9dCBGUnJmZxj0B8S8kdam4Pprfb0IOYJub6R5kV_G168UJPZkXAgTkvXUSInKXHkRzJrNtcl8LmUSfE7QZFuoGcp6Qm1FayD3w5_bHouIghS4
 
JavaScript Arrow Function
 
In this tutorial, you will learn about Arrow Function in JavaScript with the help of Example:
Arrow functions were introduced in ES6.
 
Arrow functions help us to write shorter function syntax is as follows:
 
Example 1 -
 
Output -
 
 
 
JavaScript For Of
 
The for...of statement used to creates a loop iterating over iterable objects and over the built-in String, Array, array-like objects (e.g., arguments or NodeList), TypedArray, Map, Set and user-defined iterables etc..
 
The Syntax of for Of Loop is as follows:
for (element of iterable) {
// body of for… of 
}
Example 1 -
 
https://lh5.googleusercontent.com/_Z9SAvmLCh83_6RiTIyogmkMEUiuVbv0lXSxd-RcdQ0uukNqVgLLeQf8Tdj-52DQC-O15bgisXRpVFUiCh5dqydIpZ6l9xa-Pr6A9dlq_Q-FEEt5wbH1JbAzcuA14LU3KnVpS5OW
Output -
 
https://lh6.googleusercontent.com/bgXXdnHJp8aw1JPtctaZPUiBDQ_mDGVuvJSB3GceEsxoTSrnCPzssrsxT-Uky7LXZWyPBwCbemy0zdSKpsi5QHz5lm58YXlj-y__0C5MPBNvvvhR4ni7zdoq6ymW-y0mTV4CUqAK