What Is ECMAScript 6 And Its Features And Updates

ECMAScript 6 OR ES6

ECMAScript 6 is also known as ES6 and ECMAScript 2015 aslo called javascript 6.
New features which comes with ES6 is given below

  1. let
  2. const
  3. default parameter values
  4. Array.find()
  5. Array.findIndex()
    • let keyword* let gives provides the privilege to declare variables that are limited in scope to the block, statement of expression unlike var.
ECMAScript 6 is also known as ES6 and ECMAScript 2015 aslo called javascript 6.
New features which comes with ES6 is given below

let
const
default parameter values
Array.find()
Array.findIndex()

let keyword* let gives provides the privilege to declare variables that are limited in scope to the block, statement of expression unlike var.

Support for constants – Support for const constants (also known as “immutable variables”).

const PI = 3.141593
PI > 3.0

default parameter values - Now it is easy to pass default parameter value in javascript function like
function test(x=1,y="hello",url="http://iamsuraj.in"){
}
  • Array.find() :

The find() method returns the value of the first array element that passes a test function.

var numbers = [12,16,48,78,74,12];
var findnum = numbers.find(testFunction);

function testFunction(val,index,array){
return val > 48;
}
first no 48 is 78
console.log(findnum);

  • Array.findIndex()
var numbers = [12,16,48,78,74,12];
var findnum = numbers.findIndex(testFunction);

function testFunction(val,index,array){
return val > 48;
}
First number over 18 has index is 3
console.log(findnum);

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *