What is ES6?
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)
What are the features of ES6?
- Support for constants
- Arrow functions
- Object Literals
- Promises in Es6
- Support Map/set
- Default parameters
- Rest and Spread operators
- Objects, Modules, classes, iterators, and generators in ES6
- Destructing Assignment
What is WeakMap in ES6?
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.
What is WeakSet?
The WeakSet object lets you store weakly held objects in a collection.
What’sthe Navigator-specific methods used in ES6?
Navigator-specific methods are:
- javaEnabled()
- taintEnabled()
- refresh
- preference(name,value)
For More:
What is the use of pop() method?
pop() method is used to remove the last element from an array and returns that element.
What are the number methods in ES6?
- isNaN() :Determines whether the passed value is NaN.
- isFinite() : Determines whether the passed value is a finite number.
- isInteger() :Determines whether the passed value is an integer.
- isSafeInteger() :Determines whether the passed value is a safe integer (number between -(253 – 1) and 253- 1)
- parseFloat() :The value is the same as parseFloat() of the global object
- parseInt() :The value is the same as parseInt() of the global object
Write a syntax export a single value or element in a Module?
By using export default element_name
Write a syntax export multiple values or elements in a Module?
By using export {element_name1,element_name2,….}
Can you define location.replace()?
It is the replace() method of window.location object which is used to replace the current document with a new one.
Can you define Alert Dialog Box?
It is used to send a warning message to the users and provides only one button “OK” to select and proceed.
What are iterators in ES6?
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
What are the error objects in ES6?
- EvalError: regarding the global function eval().
- RangeError :when a numeric variable or parameter is outside of its valid range.
- ReferenceError :when dereferencing an invalid reference.
- SyntaxError : while parsing the code.
- TypeError : when a variable or parameter is not of a valid type.
- URIError : when encodeURI() or decodeURI() are passed invalid parameters.
Write a creat Javascript class in ES6?
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();
Can you explain Spread operator in ES6?
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]
What is the ES6 Map feature?
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}