"JavaScript: good details" - why you can remove the name as the name of the property, when the book implies that it should not

Here is an excerpt from chapter 2:

The name cannot be one of these reserved words:

... delete ...

Further in this section:

Names are used for ... property names ...

If this is true, then why does this work in my browser console:

 > a = {}; > a.delete = 1; > a.delete + 2 === 3 true 

I am using the "Version 36.0.1985.143 m" Google Chrome for my browser and Windows 8.1 Enterprise for my OS.

Is the author a reference to property names should not be a reserved word or am I missing something?

+5
source share
1 answer

When the book was written, ECMAScript 3 ruled the earth, and that was a true statement.

However, in modern browsers, ECMAScript 5 runs, which raised this requirement.

If you have IE, put yourself in compatibility mode with IE6 or IE7 and it will not work.

By the way, even with ECMAScript 3 you can still write it as

 a["delete"] 
+5
source

Source: https://habr.com/ru/post/1200488/


All Articles