ES6 Symbol
ES6 Symbol is a unique, immutable data type used as object property keys, ensuring uniqueness. It’s primarily for internal/private use, avoiding unintended clashes in properties.
Syntax:
let symbol = Symbol();
Example: In this example, we are going to generate symbols.
Javascript
// Write Javascript code here let sym1 = Symbol() let sym2 = Symbol( 'mysymbol' ) console.log( 'Type of sym1: ' , typeof (sym1)) console.log( 'Type of sym2: ' , typeof (sym2)) |
Output
Type of sym1: symbol Type of sym2: symbol
JS 2015 or ECMAScript 6 (ES6)
JS 2015 (ES6) also known as ECMAScript 6 (ES6), ECMAScript 6 (ES6) is a significant update to JavaScript, introducing arrow functions, classes, template literals, let and const for variable declaration, enhanced object literals, destructuring, and more modern features for better code organization and readability.