In December 2009, ECMAScript released ECMAScript 5. It has been ten years since the release of the previous version of the ECMAScript 3 standard. During this period, although JavaScript was popular in web programming, ECMAScript 4 was eventually adopted by major manufacturers and organizations with relevant interests. The complexity of the language (that is, whether to add a large number of features to expand the functionality of ECMAScript) was stymied by disagreements, making the formulation of new ECMAScript standards far behind programming practices. ECMAScript 5 is less ambitious in its goals. In addition to adding support for JSON and more comprehensive control of reflection, an important improvement is the introduction of "strict mode". In this mode, the syntax of ECMAScript becomes more strict, so that many common error-prone codes are no longer allowed, including mandatory variable declarations and disallowed with statements. Adopting this mode is very simple, just add "use strict"; such a line of string to the first line of the script file or function.
The author later learned that in 2010, he wrote a small article discussing the shortcomings of the with keyword, which is attached below.
Wedge
A long time ago, the magic pen Ma Liang’s hometown wanted to name a road after him in order to commemorate him. Ma Liang did not refuse, but put forward four words of advice. Many years later, a foreigner came here and stopped a local on this road to ask for directions.
Excuse me, is this a holy road?
Yes, this is Shenma Road.
Don’t you know either?
I am the person here, how could I not know.
Then is this a holy road?
Why do you ask after you know.
I just don’t know this is a holy road.
Then didn’t I already tell you that this is a holy road?
Can you say again that this is a holy road?
......
Afterwards, the local man remembered the opinion of Ma Liang, the magic pen, and suddenly realized. What Ma Liang said is - don't use abbreviations.
A Question
One day Tom said to Wang Er, his Chinese friend, "I have a dream. I want to show myself on CCTV." The next day Tom broke into a neighbor shop . The police didn't take much time to identify and arrest Tom because he was captured very clearly by the shop's CCTV.
The question is when Tom said his dream, he is
A) ambitious B) not ambitious C)ambiguous D) unambiguous
The right answer is B) and C). . This also exists in Javascript. Sometimes it is troublesome to repeatedly reference a variable with a long name, such as:
objectWithLongName1.propty1=value1;
objectWithLongName1.propty2=value2;
objectWithLongName1. propty3=value3;
objectWithLongName1.method1();
But a clear name is very important for the readability of the program. So Javascript provides the with statement. The above example can be rewritten as: