Lecture-2: Introduction To ECMAScript 2020
Introduction To ECMAScript 2020
Lesson Outline:
Overview of ECMAScript
New features in ECMAScript 2020
Examples of new features in action
Conclusion
Overview of ECMAScript
- ECMAScript, also known as JavaScript, is a programming language that is widely used for client-side web development as well as server-side development.
- ECMAScript is standardized by the ECMAScript Language Specification and new versions of the standard are released regularly.
- ECMAScript 2020, also known as ES11, is the latest version of the language and was officially released in June 2020.
- New features in ECMAScript 2020
- BigInt: a new numeric type that allows the representation of integers larger than 2^53 - 1, which is the largest integer that can be represented by the Number type.
- Optional chaining: a new operator (?.) that allows you to access properties of an object without having to check if the object is null or undefined first.
- Nullish coalescing: a new operator (??) that allows you to provide a default value for a variable if it is null or undefined.
- String.prototype.matchAll(): a new method that returns an iterator of all matches for a regular expression in a string.
- GlobalThis: a new global object that provides a consistent way to access the global object, regardless of the environment (browser or Node.js).
- Examples of new features in action
- Using BigInt:
let x = 9007199254740991n; // 9007199254740991 is the largest integer that can be represented by Number
console.log(x); // 9007199254740991n
- Using Optional chaining:
let user = { name: "John", age: 30 };
console.log(user?.address?.zip); // undefined
- Using Nullish Coalescing:
let x = null;
let y = 0;
let z = x ?? y;
console.log(z); // 0
- Using matchAll():
let str = "Hello World";
let regex = /l/g;
let matches = str.matchAll(regex);
for (let match of matches) {
console.log(match);
}
- Using GlobalThis:
console.log(globalThis === global); // true in Node.js
console.log(globalThis === window); // true in browser
- Conclusion
- ECMAScript 2020, also known as ES11, is the latest version of the language and brings new features like BigInt, Optional chaining, Nullish coalescing, String.prototype.matchAll(), GlobalThis. These features allow for more concise and expressive code, and make common tasks easier to perform. With the release of ES11, JavaScript developers now have more powerful tools at their disposal.
5. Overview of ECMAScript
ECMAScript, also known as JavaScript, is a programming language that is widely used for client-side web development as well as server-side development. It is a high-level, dynamic, and interpreted programming language. ECMAScript is primarily used to create interactive and responsive user interfaces on websites, but it can also be used to create server-side applications using technologies like Node.js.
ECMAScript is standardized by the ECMAScript Language Specification and new versions of the standard are released regularly. The latest version of ECMAScript is ES11 (ECMAScript 2020) which was officially released in June 2020. Each version brings new features and improvements to the language, making it more powerful and versatile for developers.
Tune In For Next Lecture
.png)
Comments
Post a Comment