Tell something about ES6 and what are the new features introduced ?
Interviewer
ES6 introduced the following Features :
- let and const – var, let and const
- Template Literals – Use backticks
`
to create strings that can include variables and expressions. - Fat arrow functions – A shorter way to write functions with
=>
. - Default parameters – Set default values for function parameters.
- Enhanced object literals -A simpler way to set up objects.
- Sets and WeakSets
- Maps and WeakMaps
- Rest and Spread Operator (…) – Use
...
to work with functions that have an unknown number of arguments. - Array & Object Destructuring – A quick way to pull out values from arrays or objects.
- Classes – Makes it easier to create and manage objects in a more organized way.
- Promises – A new system for handling tasks that might take some time to finish.
- Generators – A way to make functions that can pause and resume, useful for certain types of tasks.