Dock  Koelpin

Dock Koelpin

1611980580

ECMAScript-2021/ES12 - JavaScript Latest Features

This Video Covers JavaScript 2021 / ES 12/ ECMA 2021 Latest Features.

  1. String Replace All
  2. Promise Any method
  3. Logical Assignment Operator
  4. Numeric Separation
  5. Private Methods
  6. Weak Ref and Finalizer

#javascript #web-development #programming #developer

What is GEEK

Buddha Community

ECMAScript-2021/ES12 -  JavaScript Latest Features
Julie  Donnelly

Julie Donnelly

1602372660

JavaScript ES2021 Exciting Features

Every year, JavaScript update adds new features. This year ES2020 or ES11 was released (Read ES2020 features article), with ES2021 or ES12 expected to be released in mid-2021.

New features that are added to JavaScript each year go through a four-stage process, with the fourth stage being the last one. In this article, I will discuss the features that have already reached stage four and are added to the Google Chrome V8 engine.

List of the new features discussed in this article

  • String.prototype.replaceAll
  • Promise.any
  • Logical Operators and Assignment Expressions
  • Numeric Separators
  • Intl.ListFormat
  • dateStyle and timeStyle options for Intl.DateTimeFormat

#javascript-introduction #javascript #es12 #javascript-tips #es2021

Rahul Jangid

1622207074

What is JavaScript - Stackfindover - Blog

Who invented JavaScript, how it works, as we have given information about Programming language in our previous article ( What is PHP ), but today we will talk about what is JavaScript, why JavaScript is used The Answers to all such questions and much other information about JavaScript, you are going to get here today. Hope this information will work for you.

Who invented JavaScript?

JavaScript language was invented by Brendan Eich in 1995. JavaScript is inspired by Java Programming Language. The first name of JavaScript was Mocha which was named by Marc Andreessen, Marc Andreessen is the founder of Netscape and in the same year Mocha was renamed LiveScript, and later in December 1995, it was renamed JavaScript which is still in trend.

What is JavaScript?

JavaScript is a client-side scripting language used with HTML (Hypertext Markup Language). JavaScript is an Interpreted / Oriented language called JS in programming language JavaScript code can be run on any normal web browser. To run the code of JavaScript, we have to enable JavaScript of Web Browser. But some web browsers already have JavaScript enabled.

Today almost all websites are using it as web technology, mind is that there is maximum scope in JavaScript in the coming time, so if you want to become a programmer, then you can be very beneficial to learn JavaScript.

JavaScript Hello World Program

In JavaScript, ‘document.write‘ is used to represent a string on a browser.

<script type="text/javascript">
	document.write("Hello World!");
</script>

How to comment JavaScript code?

  • For single line comment in JavaScript we have to use // (double slashes)
  • For multiple line comments we have to use / * – – * /
<script type="text/javascript">

//single line comment

/* document.write("Hello"); */

</script>

Advantages and Disadvantages of JavaScript

#javascript #javascript code #javascript hello world #what is javascript #who invented javascript

Main ECMAscript 2021 Features

I have been using the new features of ECMAScript 2021 for over a year, thanks to Babel. Almost all the features are usable, but I liked only Four of them it helps me to write efficient and better code, Let’s begin with first,

#javascript-tips #javascript #ecmascript

Hire Dedicated JavaScript Developers -Hire JavaScript Developers

It is said that a digital resource a business has must be interactive in nature, so the website or the business app should be interactive. How do you make the app interactive? With the use of JavaScript.

Does your business need an interactive website or app?

Hire Dedicated JavaScript Developer from WebClues Infotech as the developer we offer is highly skilled and expert in what they do. Our developers are collaborative in nature and work with complete transparency with the customers.

The technology used to develop the overall app by the developers from WebClues Infotech is at par with the latest available technology.

Get your business app with JavaScript

For more inquiry click here https://bit.ly/31eZyDZ

Book Free Interview: https://bit.ly/3dDShFg

#hire dedicated javascript developers #hire javascript developers #top javascript developers for hire #hire javascript developer #hire a freelancer for javascript developer #hire the best javascript developers

7 New ECMAScript 2022 Features | The Latest ES13 JavaScript Features

ECMAScript 2022, the 13th edition, introduced top-level await, allowing the keyword to be used at the top level of modules; new class elements: public and private instance fields, public and private static fields, private instance methods and accessors, and private static methods and accessors; static blocks inside classes, to perform per-class evaluation initialization; the #x in obj syntax, to test for presence of private fields on objects; regular expression match indices via the /d flag, which provides start and end indices for matched substrings; the cause property on Error objects, which can be used to record a causation chain in errors; the at method for Strings, Arrays, and TypedArrays, which allows relative indexing; and Object.hasOwn, a convenient alternative to Object.prototype.hasOwnProperty.

On 22 June 2022, the 123nd Ecma General Assembly approved the ECMAScript 2022 language specification, which means that it’s officially a standard now.

What’s new in ECMAScript 2022 (JavaScript ES13)?  

  1. New members of classes
  2. Private slot checks via the in operator
  3. Top-level await in modules
  4. error.cause
  5. Method .at() of indexable values
  6. RegExp match indices
  7. Object.hasOwn(obj, propKey)

1 - New members of classes

class MyClass {
  instancePublicField = 1;
  static staticPublicField = 2;

  #instancePrivateField = 3;
  static #staticPrivateField = 4;

  #nonStaticPrivateMethod() {}
  get #nonStaticPrivateAccessor() {}
  set #nonStaticPrivateAccessor(value) {}

  static #staticPrivateMethod() {}
  static get #staticPrivateAccessor() {}
  static set #staticPrivateAccessor(value) {}

  static {
    // Static initialization block
  }
}

2 - Private slot checks via the in operator  

Private slot checks are also called “ergonomic brand checks for private fields”. The following expression is such a check – it determines if obj has a private slot #privateSlot:

#privateSlot in obj

This is an example:

class ClassWithPrivateSlot {
  #privateSlot = true;
  static hasPrivateSlot(obj) {
    return #privateSlot in obj;
  }
}

const obj1 = new ClassWithPrivateSlot();
assert.equal(
  ClassWithPrivateSlot.hasPrivateSlot(obj1), true
);

const obj2 = {};
assert.equal(
  ClassWithPrivateSlot.hasPrivateSlot(obj2), false
);

More information on private slot checks.

3 - Top-level await in modules 

We can now use await at the top levels of modules and don’t have to enter async functions or methods anymore:

// my-module.mjs
const response = await fetch('https://example.com');
const text = await response.text();
console.log(text);

More information on top-level await.

4 - error.cause 

Error and its subclasses now let us specify which error caused the current one:

try {
  // Do something
} catch (otherError) {
  throw new Error('Something went wrong', {cause: otherError});
}

The cause of an error err shows up in the stack trace and can be accessed via err.cause.

More information on error.cause.

5 - Method .at() of indexable values 

Method .at() of indexable values lets us read an element at a given index (like the bracket operator []) and supports negative indices (unlike the bracket operator):

> ['a', 'b', 'c'].at(0)
'a'
> ['a', 'b', 'c'].at(-1)
'c'

The following “indexable” types have method .at():

  • string
  • Array
  • All Typed Array classes: Uint8Array etc.

More information on method .at() of indexable values.

6 - RegExp match indices

If we add the flag /d to a regular expression, using it produces match objects that record the start and end index of each group capture (lines A and B):

const matchObj = /(a+)(b+)/d.exec('aaaabb');

assert.equal(
  matchObj[1], 'aaaa'
);
assert.deepEqual(
  matchObj.indices[1], [0, 4] // (A)
);

assert.equal(
  matchObj[2], 'bb'
);
assert.deepEqual(
  matchObj.indices[2], [4, 6] // (B)
);

More information on RegExp match indices.

7 - Object.hasOwn(obj, propKey)

Object.hasOwn(obj, propKey) provides a safe way to check if an object obj has an own (non-inherited) property with the key propKey:

const proto = {
  protoProp: 'protoProp',
};
const obj = {
  __proto__: proto,
  objProp: 'objProp',
}

assert.equal('protoProp' in obj, true); // (A)

assert.equal(Object.hasOwn(obj, 'protoProp'), false); // (B)
assert.equal(Object.hasOwn(proto, 'protoProp'), true); // (C)

Note that in detects inherited properties (line A), while Object.hasOwn() only detects own properties (lines B and C).

More information on Object.hasOwn().

#javascript #es13 #ecmascript #programming