There are no items in your cart
Add More
Add More
Item Details | Price |
---|
Sun Jan 1, 2023
ECMAScript 6 (also known as ES6 or ECMAScript 2015) is a version of JavaScript that introduced several new features to the language. Here are a few examples:
let
and const
: ES6 introduced two new ways to declare variables: let
and const
. let
is similar to the var
keyword, but variables declared with let
are block-scoped, rather than function-scoped. const
is used to declare variables that cannot be reassigned.let add = (a, b) => a + b;
) instead of single or double quotes, and variables are denoted by a dollar sign and curly braces (
${}`)let name = "John"; console.log(`Hello, ${name}!`);
let [a, b, c] = [1, 2, 3];let {x, y, z} = {x: 1, y: 2, z: 3};
class Person { constructor(name) { this.name = name; } sayHello() { console.log("Hello, my name is " + this.name); } }
// myModule.js export let x = 1; export function add(a, b) { return a + b; }// main.js import {x, add} from "./myModule.js"; console.log(x); // 1 console.log(add(1, 2)); // 3
These are just a few examples; many more features are introduced in ES6, such as Promises, Symbol, Generators, etc.
DCT Academy
Full Stack web development training institute in Bangalore