What falls under ECMAScript
What will come with ECMAScript 2020
In the summer, seven features will be officially released as part of ECMAScript 2020. There is also an extension of the specification for the for-in loop. The new functions include shortened notations, a new data type and the ability to increase the performance of websites. This article introduces the new features.
Optional chaining operator
The new optional chaining operator introduces a shortened notation that makes it easier to check for undefined values. Especially when working with data from interfaces, it can never be assumed that all data is actually included. It often happens that a data record is only partially filled or not at all. To ensure that the software does not crash, for example when performing a function on an undefined data record, it must first be checked whether it has been properly filled. The usual notation for this is the ternary operator:const tomatoes = recipes.pasta
If is defined, save the number of tomatoes, otherwise return. This notation can quickly take up a lot of space, for example if several levels of the object are undefined at the same time. In this case there must be a separate ternary operator for each of the layers.
An alternative notation is the classic test with an if construction, in which the functionality is only executed when the value is filled. Although the spelling also leads to the desired result, it also takes up a lot of space. The new optional chaining offers a defined, shortened notation:const tomatoes = recipes.pasta? .tomatoes;
The operator checks whether the value is filled and then saves the number of tomatoes. The new extension can be called up as often as required if several levels are to be checked. The call chain breaks off if one of the elements is not filled and returns a. It is also possible to use the operator on an array.const shopping list = ['eggs', 'milk'];
const pasta = shopping list?. ;
In this case, the optional chaining operator can be used to access the index of an array without knowing whether the array or the specific index is present. The behavior is the same for functions.print.recipes?. ('soup');
- There are bears in Austin, TX
- What are paid media
- Who uses the slang Presstitute and why
- What was Vincent Price's best film
- What is common between Islam and Christianity
- What's the worst water brand
- A GIDC comes to Gujarat
- How does democracy hinder global economic growth?
- When would you do business in India?
- Eat and kill crickets bed bugs
- Why are there no rich communist countries
- What is a residence permit in Germany
- Actresses have armpit hair
- Why did Mother Teresa lose her faith
- Is Kanye West an idiot
- Can a minor rape an adult
- What does a wrong flag mean?
- Is the threading of the face bad for the skin?
- How is parking in Norwich, NY
- What is the first letter in Thirukkural
- What can I expect from the lifeguard training?
- What's the best thing about Emirates Airlines
- What's the screaming fandom out there
- Why don't South Indians learn Hindi?