ES6 stands for ECMAScript version 6. It is a Client-side scripting language. Now,10th edition ECMAScript 2019, was published in June 2019.
Read More: Intr0duction to ECMAScript (ES)
The WeakMap is same as Map where it is a collection of key/value pairs. But in WeakMap, the keys must be objects and the values can be arbitrary values.
The WeakSet object lets you store weakly held objects in a collection.
Navigator-specific methods are:
- javaEnabled()
- taintEnabled()
- refresh
- preference(name,value)
pop() method is used to remove the last element from an array and returns that element.
By using export default element_name
By using export {element_name1,element_name2,….}
It is the replace() method of window.location object which is used to replace the current document with a new one.
It is used to send a warning message to the users and provides only one button “OK” to select and proceed.
An iterator accesses the items from a collection one at a time, while keeping track of its current position within that sequence. It provides a next () method which returns the next item in the sequence. This method returns an object with two properties: done and value
In Es6 you can create a class using the Class keyword.Below is sample javascript class in ES6.
class User{
constructor(name,age) {
this.name = name;
this.age = age;
}
getData() {
console.log(this.name + " is " + this.age + " years old !");
}
}
var user = new User("foo", 7);
s1.getData();
It provides a new way to manipulate array and objects in Es6.A Spread operator is represented by … followed by the variable name.Check below Example:
let a =[6,7,8,9];
let b=[1,2,3,...a,10];
console.log(b);
output: // [1,2,3,6,7,8,9,10]
The Map object is a simple key/value map. Any value (both objects and primitive values) may be used as either a key or a value. Syntax [key, value]. e.g.
hash = new Map ()
hash.set ("hello", 44)
hash.set (1, 38);
console.log (hash); //Map {"hello" => 44, 1 => 38}