egerx.blogg.se

Es6 new features
Es6 new features









In the second part of the above program, we check not a number in the array. In a second way, we try to find out the element by using the index of the array as shown. If an element is present in the array then the print message element is found otherwise the element is not found. Here we check if 20 is present or not in the array. In the first way, we try to find elements in a given array. In this example, we implement an array.include() function by using two methods as shown. In the above example, we try to implement the array.includes() function. We can also provide the index of value with the specified value.Ĭonsole.log('Element is found in given array')Ĭonsole.log(' Element is not found in given array ')Ĭonsole.log(‘Element is found in specified array index’)Ĭonsole.log(' Element is not found in specified array index ')Ĭonsole.log(students.includes(student 1))Ĭonsole.log(students.includes(student 3)) This technique returns valid assuming that the worth is found, else returns bogus assuming that the worth doesn’t exist.īy using the above syntax we can implement another feature of ES7. includes() strategy acknowledges a boundary, checks assuming the worth passed as boundary exists in the cluster. The indexof() returns the list of the principal event of the component in the exhibit assuming the information is found, else returns – 1 on the off chance that the information doesn’t exist.

es6 new features

Preceding ES7, the indexof() strategy for the Array class could be utilized to confirm on the off chance that a worth exists in a cluster. includes() strategy in ES7 assists with checking to assume a component is accessible in a cluster.

es6 new features

The final output of the above implementation we illustrated by using the following screenshot as follows. After that, we print the result with Math.pow() function and with function. In the above example, we try to implement the exponentiation operator as shown, here we first need to declare the base value and exponent value as shown.











Es6 new features