[2022] 🔥 ES6 Interview Questions Answer 🌞
Tags: javascript, career, webdev, beginners
Published: 2021-11-15 17:18:10


FULL Article Is Here https://bhylu.com/interview-questions/es6-interview-questions-and-answers/

#1. Mention some popular features of ES6.

Some of the common ES6 features are:

Supports constants/immutable variables.
Block scope support for all variables, constants and functions.
Introduction to arrow functions
Handling extended parameter
Default parameters
Extended and template literals
De-structuring assignment
Promises
Classes
Modules
Collections
Supports Map/Set & Weak-map/Weak-Set
Localization, meta-programming, internationalization

#2. What are the object oriented features supported in ES6.
The object-oriented features supported in ES6 are:

Classes: We can create classes in ES6. The class function essentially builds a template from which we may later create objects. When a new instance of the class is created, the constructor method is invoked.
Methods: Static methods can also be found in classes. A static method, unlike an object, is a function that is bound to the class. A static method can't be called from a class instance.
Let's take a look at getters and setters for a moment. Encapsulation is a fundamental notion in OOP. Data (object properties) should not be directly accessed or updated from outside the object, which is a crucial aspect of encapsulation. A getter (access) or a setter (modify) are particular methods we define in our class to access or edit a property.
Inheritance: It is also possible for classes to inherit from one another. The parent is the class that is being inherited from, and the child is the class that is inheriting from the parent.
 
#3. Give a thorough comparison between ES5 and ES6.
ES5	ES6
ES5 is the fifth edition of the ECMAScript which was introduced in 2009.	ES6 is the sixth edition of the ECMAScript which was introduced in 2015.
Primitive data types that are string, boolean, number, null, and undefined are supported by ES5.	There are a few additions to the JavaScript data types in ES6.  For supporting unique values, a new primitive data type 'symbol' was introduced.
In ES5, we could define the variables by using the var keyword only.	In ES6, in addition to var, there are two new methods to define variables: let and const.
Both function and return keywords are used in order to define a function in ES5.	An arrow function is a newly added feature in ES6 in which we don't require the function keyword in order to define the function.
In ES5, a for loop is used to iterate over elements.	ES6 introduced the idea of for...of loop in order to iterate over the values of the iterable objects.
4. What is the difference between let and const? What distinguishes both from var?
When declaring any variable in JavaScript, we used the var keyword. Var is a function scoped keyword. Within a function, we can access the variable. When we need to create a new scope, we wrap the code in a function.

Both let and const have block scope. If you use these keywords to declare a variable, it will only exist within the innermost block that surrounds them. If you declare a variable with let inside a block (for example, if a condition or a for-loop), it can only be accessed within that block.

The variables declared with the let keyword are mutable, which means that their values can be changed. It's akin to the var keyword, but with the added benefit of block scoping. The variables declared with the const keyword are block-scoped and immutable. When variables are declared with the const keyword, their value cannot be modified or reassigned.


4. Discuss the arrow function.
In ES6, arrow functions are introduced. The shorthand syntax for writing ES6 functions is arrow functions. The arrow function's definition consists of parameters, followed by an arrow (=>), and the function's body.

The 'fat arrow' function is another name for the Arrow function. We won't be able to employ them as constructors.

 const function_name = (arg_1, arg_2, arg_3, ...) => {  
    //body of the function  
} 
Few things to note:

It reduces the size of the code.
For a single-line function, the return statement is optional.
Bind the context lexically.
For a single-line statement, functional braces are not required.
Doesn’t work with new

###Full article is https://bhylu.com/interview-questions/es6-interview-questions-and-answers/