Symbol

Symbol is a type of primitive data type intriduced in ES6. It is used to specify the hidden identifiers that can not be directly accessed by any other code.

Example: The use of the Symbol data type is explained in the below code example.

Javascript




const gfg = {
    name: "w3wiki",
    desc: "A Computer Science portal for all geeks."
}
 
let short_name = Symbol("short_name")
gfg.short_name = "GFG";
console.log(`${gfg.name}, \n${gfg.desc}`);
console.log(`Company's Short Name using gfg.short_name: ${gfg.short_name} `)
console.log(`Company's Short Name using gfg[short_name]: ${gfg[short_name]} `)


Output

w3wiki, 
A Computer Science portal for all geeks.
Company's Short Name using gfg.short_name: GFG 
Company's Short Name using gfg[short_name]: undefined 

Introduction to ES6

ES6 or ECMAScript 2015 is the 6th version of the ECMAScript programming language. ECMAScript is the standardization of Javascript which was released in 2015 and subsequently renamed as ECMAScript 2015.
ECMAScript and Javascript are both different.

Similar Reads

ECMAScript vs Javascript

ECMAScript: It is the specification defined in ECMA-262 for creating a general-purpose scripting language. In simple terms, it is a standardization for creating a scripting language. It was introduced by ECMA International and is an implementation with which we learn how to create a scripting language....

ES6

Javascript ES6 has been around for a few years now, and it allows us to write code in a clever way which basically makes the code more modern and more readable. It’s fair to say that with the use of ES6 features we write less and do more, hence the term ‘write less, do more’ definitely suits ES6....

const

The const keyword is used to declare constant variables whose values can’t be changed. It is an immutable variable except when used with objects....

let

...

Arrow functions

The let variables are mutable i.e. their values can be changed. It works similar to the var keyword with some key differences like scoping which makes it a better option when compared to var....

Template literal

...

Object and Array Desctructuring

Arrow functions are a more concise syntax for writing function expressions. These function expressions make your code more readable, and more modern....

Default Parameters

...

Classes

It allows us to use the JavaScript variables with the string without using the ‘+’ operator. Template literal defined using (“) quotes....

Rest parameter and spread operator

...

for/of Loop

Destructing in javascript basically means the breaking down of a complex structure(Objects or arrays) into simpler parts. With the destructing assignment, we can ‘unpack’ array objects into a bunch of variables....

JavaScript Maps and Sets

...

Promises

In ES6, we can declare a function with a default parameter with a default value....

Symbol

...

String Methods

ES6 introduced classes in JavaScript. Classes in javascript can be used to create new Objects with the help of a constructor, each class can only have one constructor inside it....

Array Methods

...

Object Enteries

Rest Parameter: It is used to represent a number of parameter in an array to pass them together to a function....