In ES7/ES2016 new feature was an alternative to the feature which was there before ES7. In the Javascript ES7 Features no new functionality was introduced.
Javascript ES7 Features
Includes
ES7 has introduced a new feature “includes” to check whether a given element exists in an array. Before ES7 indexOf was used to check whether elements exist in an array or not. If the indexOf Element return -1 then the element does not exist or else the indexOf returns the position of the given element.
Array.includes() return boolean value for the given parameter. If found then return true or else return false. It is case sensitive.
SYNTAX : Array.includes(value,start_index)
let infohubblogcontent = ["Tech News","Javascript","AWS","Gaming"]; let output=infohubblogcontent.includes("Tech News")?"Content is Avaiable in InfoHubBlog":"Sorry!"; console.log(output); //OUTPUT:Content is Avaiable in InfoHubBlog

If You want to search after a specific index whether the value exists or not then you can pass start_index as a parameter in Array.includes(). The default value of start_index is 0.
let infohubblogcontent = ["Tech News","Javascript","AWS","Gaming"]; let output=infohubblogcontent.includes("Tech News",1)?"Content is Avaiable in InfoHubBlog":"Sorry!"; console.log(output); //OUTPUT:Sorry!

It cannot be used with an object that exists in Array as an element. This will return a false value.
let infohubblogcontent = [{"Tech":"Tech News"}]; let output=infohubblogcontent.includes({"Tech":"Tech News"})?"Content is Avaiable in InfoHubBlog":"Sorry!"; console.log(output); //OUTPUT:Sorry!

Exponential Operator
It is the new mathematical operator. Alternative for Exponential already exists i.e. Math.pow(). The exponential operator is represented by double astrick “**”. It can only be used with numeric values. Below is a comparison of Exponential Operator with Math.pow().
let a= 2**4; let b= Math.pow(2,4) let output=a==b?"Both are Equal":"Not Equal"; console.log(output); //OUTPUT: Both are Equal

Hope you like our “Important Javascript ES7 Features” blog. Please subscribe to our Blog for upcoming blogs.
Happy Coding!
Read more: Important Javascript ES8 Features, Important ES9 Javascript Feature, Important Javascript ES10 Features, Top ES11 Features | Javascript, Different types of While For Loop Javascript ES6, ECMAScript
Leave a comment