100% found this document useful (1 vote)
360 views2 pages

Overview of ECMAScript 6 Features

ES6 is the latest version of ECMAScript that introduced many new features like arrow functions, classes, modules, promises etc. It supports features like template literals for multiline strings, rest/spread properties, destructuring, block scoping etc. Classes introduce inheritance through the extends keyword and static methods. Sets, Maps and Symbols are new data types introduced in ES6. Promises are used for asynchronous programming and have 3 states - pending, fulfilled and rejected. Variables declared with let, const and class have block scope unlike var.

Uploaded by

Shantha Moorthy
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
360 views2 pages

Overview of ECMAScript 6 Features

ES6 is the latest version of ECMAScript that introduced many new features like arrow functions, classes, modules, promises etc. It supports features like template literals for multiline strings, rest/spread properties, destructuring, block scoping etc. Classes introduce inheritance through the extends keyword and static methods. Sets, Maps and Symbols are new data types introduced in ES6. Promises are used for asynchronous programming and have 3 states - pending, fulfilled and rejected. Variables declared with let, const and class have block scope unlike var.

Uploaded by

Shantha Moorthy
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

ECMAScript6

----------------
ES6 is the implementation of? - ECMAScript
All major JavaScript Implementations are based on which standard? - ECMAScript
ES6 is officially called _ - ECMA Script 2015
ECMAScript is a _ - Language Standard
ES6 can be used for __ - both
How many parts are there in an ES6 module? - 2
----------------
"Rest" collects all variables into a single array, while "Spread" expands a single
variable into multiple. - true
Which of the following parameters can be used to expand a single array into
multiple arguments? - Spread
const { x, y } = { x: 11, y: 8 }; is the Same as const { x: x, y: y } = { x: 11, y:
8 }; - true
During destructuring, you can either declare variables or assign to them, or both.
- false
Which of the following parameters can be used to define indefinite number of
parameters in one single array? - Rest
What will be the output of following code snippet? - 6,5
function foo(a = 10, b = 5) {
[Link](a, b);
}
foo(6);
The following code implements the ______ feature of ES6 - spread
Destructuring helps us to extract multiple values from an object via - Object
Pattern
---------------------
Template literals can be defined as _ - multi-line string literals that support
interpolation
What will be the output of the following code snippet? - 23
const func= (
x,
y
) => {
return x + y;
};
func(11,12);

Arrow Functions are less verbose than traditional functions - True


Template literals support - interpolation
Template literals can be reused _ true
Instead of using single quotes or double quotes, es6 uses BACKTICK or OPENQUOTE ( "
` " ) character to create destructuring pattern. - false
Variables declared in a scope are accessible in _ - All scopes nested inside it
In Arrow functions, if there is only one parameter and that parameter is an
identifier then the parentheses can be omitted. - true
Which is not a lexical inside arrow functions? - none

Template literals does not allow us to _ - not corect build complex html and xml
templates.
Select the wrong code Snippet - not correct const func5 = (x, y) => x + y;
---------------------
Which keywords can be used to implement inheritance in ES6? - extends
_ feature helps us to simplify the inheritance concept. - classes
The bodies of class declarations and class expressions are executed in strict mode.
- true
Which is not true about constructor in ES6? - A class may have any number of
constrcutors
Which is not true about static methods? - Static methods can be directly called
with the help of a class object.
Sets can be used to store _ - Heterogeneous data
We can use this data-type to avoid repetitions. - sets

Map can use _______ value as Key. - any


Maps can be used to store _ - Key - value pairs
----------------------
Symbols can be created using the factory function - Symbol()
What will be the output of this code? var sym = new Symbol(); - Syntax Error
What will be printed if the following code is executed? - 1

let x=150;
if(x>100)
{
x=1;
}
[Link](x);
Objects declared as "const" are immutable. - false
What is the meaning of the following line of code? const pi=3.14; - Const turns
variables into constants, and they can’t be changed.
Declaring variables with which of the following keywords, will make the variable
immutable? - var
A Promise has _________ number of states. - 3
What is the scope of the variable "a" in function below? - block

function val(x){
if(x>0){
let a = x;
[Link](a);
}
}
Variables declared with which of the following constructs do not have block scope?
- const
Keyword "let" allows redeclaring variables. - FALSE
Which of the following statements is not true about level of scope? - I & III are
true and II and IV are false.
I. let keyword declares a block scoped variable.
II. var keyword declares a block scoped variable.
III. const keyword declares a block scoped variable.
IV. let and const are similiar to each other.
What is the significance of the following code snippet? The variable i is valid
only inside the for loop
for (let i = 0; i < 10; i++) {
x += 10;
}
Which of the following does not declare a block scoped variable? - var
Promise reactions are callbacks that you register with the Promise method then(),
to be notified of a fulfillment or a rejection. - true
What if promise2 get rejected in the following syntax? [Link](promise1,
promise2, .....) - It will reject the entire set
Which method can be used to retrieve symbols from the global symbols registry? -
[Link]()
Which of the following is not a state of Promise? - Approved
--------------------
It is always a good practice to physically separate the code based on _ - mostly
Functionality **** not all
ES6 modules are stored in _ - files

Common questions

Powered by AI

Promises in ES6 offer a cleaner, more organized method for handling asynchronous operations by providing a way to handle eventual successes or failures of asynchronous code execution. They improve upon callback functions by avoiding "callback hell" and enabling more manageable flows through then(), catch(), and finally() methods .

ES6 modules provide a structure for organizing and managing code by designating two parts: an export and an import section. This feature was not standardized in previous ECMAScript versions, allowing for more modular, scalable, and maintainable development .

Classes in ES6 introduce a clear, concise syntax for creating objects and handling inheritance, replacing the verbose prototype-based approach of ES5. The 'extends' keyword and more structured 'constructor' functions streamline the process, making it easier to implement and manage inheritance hierarchies .

While 'const' prevents reassignment of a variable, it doesn't make objects immutable. Thus, while primitives assigned to 'const' truly behave as constants, objects can still have their properties altered. This distinction is crucial for developing accurate and bug-free code .

Symbols provide a way to create unique identifiers that prevent naming conflicts, especially useful in defining object properties that should not collide with other properties. Created through the Symbol() factory function, they offer a higher level of abstraction and security for property access and definition .

Arrow functions reduce code verbosity by providing a more concise syntax for writing functions. They eliminate the need for the 'function' keyword and curly braces when there is a single statement, directly returning the expression's value, which can lead to more readable and manageable code .

Sets provide an efficient way to store unique values of any type, thus simplifying the management of duplicates and enhancing performance when checking for item existence. This feature is particularly advantageous when maintaining collections of data where duplicates are not desired .

Block scope introduced via 'let' and 'const' in ES6 enhances variable management by limiting their accessibility to the block in which they are defined, thus avoiding possible errors from variables being accessed outside their intended context — a problem prevalent with 'var' in earlier ECMAScript versions .

The 'rest' operator collects all remaining elements into a single array, effectively condensing multiple arguments. In contrast, the 'spread' operator takes an array or an object and expands its elements into individual arguments, useful for passing array elements as function parameters .

Template literals allow developers to create multi-line strings and include interpolations, making string manipulation more straightforward and flexible compared to the traditional approach of concatenation. This feature greatly enhances the readability and functionality of strings in ES6 .

You might also like