Home Web Front-end JS Tutorial JavaScript Advanced Programming (3rd Edition) Study Notes 13 ECMAScript5 New Features_Basic Knowledge

JavaScript Advanced Programming (3rd Edition) Study Notes 13 ECMAScript5 New Features_Basic Knowledge

May 16, 2016 pm 05:49 PM
new features

The next step should be BOM and HTML5, but since ECMAScript5 has many new changes compared to ECMAScript3, and these changes are also very interesting, I will summarize the interesting changes (not all changes) that I think in this article. But this is just a list without going into details.

1. Syntax changes

1. Keywords and reserved words

In ES3, using keywords as identifiers will result in "Identifier Expected" ” error, whereas using a reserved word for an identifier may or may not result in the same error, depending on the specific engine. In ES5, although keywords and reserved words cannot be used as identifiers, they can be used as property names of objects. Among the keywords and reserved words in ES5, let and yield are newly added. In order to ensure maximum compatibility, keywords and reserved words in ES3 or ES5 should not be used as identifiers.

2. Attribute characteristics

ES5 allows the use of user-defined attribute descriptions to override the enumerable, configurable, writable, get, set and other attributes of a given attribute. The specific method is to use static functions defined on the Object object.

3. Strict mode

The biggest grammatical change is the introduction of strict mode. You can turn on strict mode through the statement "use strict"; and add the entire script at the top of the code to enable strict mode. Adding it inside a function enables strict mode only for that function. The main changes in strict mode are:

(1) Variables must be defined before using them, that is, implicit global variables are not allowed

(2) Octal data is not used

(3) Do not use the with statement

(4) eval

A. You cannot use eval as an identifier, so you cannot name a variable or function eval

B. Variables defined in the eval() function cannot be accessed externally

(5) arguments

A. Arguments cannot be used as identifiers

B. Internal objects as functions cannot be modified arguments, so there are no longer synchronous changes between formal parameters and arguments

C. Cannot access arguments.callee

D. The arguments.caller attribute is defined in ES5, and its value is always undefined, mainly used to distinguish arguments.caller and function caller, but cannot be accessed in strict mode

(6) Function

A. Two formal parameters with the same name cannot appear in a function

B. You cannot assign a value to the caller attribute of the function

C. When calling a function without specifying an environment object, the this value will not point to the window, but to the undefined

(7) object

A. Two properties with the same name cannot appear in the object

B. When modifying an attribute whose property [[writable]] is false, an exception will be thrown instead of failing silently. The same When using delete to delete an attribute whose attribute [[configurable]] is false, an exception will also be thrown

(8) delete

You cannot use delete to delete explicitly declared variables and functions

2. Changes in built-in objects

1. Object object

(1) Inherit related methods: create(), getPrototypeOf()

(2) Attribute related methods: defineProperty(), defineProperties(), getOwnPropertyDescriptor(), getOwnPropertyNames(), keys()

(3) Anti-tampering methods: preventExtensions(), isExtensible(), seal( ), isSealed(), freeze(), isFrozen()

2. Function object

(1) Added bind() method.

(2) Normalizes the attribute caller of a function object, which is used to point to a reference to the function that calls the current function.

(3) prototype is non-enumerable

3. Array object

(1) Judgment method: Added static method Array.isArray(obj) for judgment Whether obj is an instance of an Array object.

(2) Index method: Added two methods indexOf() and lastIndexOf() for finding the index of a specified item. Use congruent (===) for matching when searching.

(3) Iteration method: added every(), some(), forEach(), map(), filter() methods.

(4) Reduce method: Added reduce() and reduceRight() methods.

4. String object

Added trim() method.

5. JSON object

Added native JSON built-in object.

6. Date object

Added Date.now(), Date.prototype.toJSON() and other methods.

7. RegExp object

In ES3, a RegExp instance is shared when using a regular expression literal, but in ES5, a new one must be created every time a regular expression literal is used. RegExp instance, just like using the RegExp constructor.

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP 8.3 released: new features at a glance PHP 8.3 released: new features at a glance Nov 27, 2023 pm 12:52 PM

PHP8.3 released: Overview of new features As technology continues to develop and needs change, programming languages ​​are constantly updated and improved. As a scripting language widely used in web development, PHP has been constantly improving to provide developers with more powerful and efficient tools. The recently released PHP 8.3 version brings many long-awaited new features and improvements. Let’s take a look at an overview of these new features. Initialization of non-null properties In past versions of PHP, if a class property was not explicitly assigned a value, its value

A guide to learn the new features of PHP8 and gain an in-depth understanding of the latest technology A guide to learn the new features of PHP8 and gain an in-depth understanding of the latest technology Dec 23, 2023 pm 01:16 PM

An in-depth analysis of the new features of PHP8 to help you master the latest technology. As time goes by, the PHP programming language has been constantly evolving and improving. The recently released PHP8 version provides developers with many exciting new features and improvements, bringing more convenience and efficiency to our development work. In this article, we will analyze the new features of PHP8 in depth and provide specific code examples to help you better master these latest technologies. JIT compiler PHP8 introduces JIT (Just-In-Time) compilation

What are the new features of php8 What are the new features of php8 Sep 25, 2023 pm 01:34 PM

New features of php8 include JIT compiler, type deduction, named parameters, union types, properties, error handling improvements, asynchronous programming support, new standard library functions and anonymous class extensions. Detailed introduction: 1. JIT compiler, PHP8 introduces the JIT compiler, which is an important performance improvement. The JIT compiler can compile and optimize some high-frequency execution codes in real time, thereby improving the running speed; 2. Type derivation , PHP8 introduces the type inference function, allowing developers to automatically deduce the type of variables when declaring variables, etc.

An overview of the new features of CSS3: How to use CSS3 to achieve transition effects An overview of the new features of CSS3: How to use CSS3 to achieve transition effects Sep 09, 2023 am 11:27 AM

Overview of the new features of CSS3: How to use CSS3 to achieve transition effects CSS3 is the latest version of CSS. Among the many new features, the most interesting and practical one should be the transition effect. Transition effects can make our pages smoother and more beautiful during interaction, giving users a good visual experience. This article will introduce the basic usage of CSS3 transition effects, with corresponding code examples. transition-property attribute: Specify the CSS property transition effect that needs to be transitioned

Interpretation of new features of Go language: making programming more efficient Interpretation of new features of Go language: making programming more efficient Mar 10, 2024 pm 12:27 PM

[Interpretation of new features of Go language: To make programming more efficient, specific code examples are needed] In recent years, Go language has attracted much attention in the field of software development, and its simple and efficient design concept has attracted more and more developers. As a statically typed programming language, Go language continues to introduce new features to improve development efficiency and simplify the code writing process. This article will provide an in-depth explanation of the latest features of the Go language and discuss how to experience the convenience brought by these new features through specific code examples. Modular development (GoModules) Go language from 1

Overview of the new features of CSS3: How to use CSS3 to achieve horizontally centered layout Overview of the new features of CSS3: How to use CSS3 to achieve horizontally centered layout Sep 09, 2023 pm 04:09 PM

Overview of the new features of CSS3: How to use CSS3 to achieve horizontally centered layout In web design and layout, horizontally centered layout is a common requirement. In the past, we often used complex JavaScript or CSS tricks to achieve this. However, CSS3 introduced some new features that make horizontally centered layouts simpler and more flexible. This article will introduce some new features of CSS3 and provide some code examples to demonstrate how to use CSS3 to achieve horizontally centered layout. 1. Use flexbox to layout fle

New Redis extension introduced in PHP8.1 New Redis extension introduced in PHP8.1 Jul 07, 2023 pm 09:41 PM

The new Redis extension introduced in PHP8.1 With the rapid development of the Internet, a large amount of data needs to be stored and processed. In order to improve the efficiency and performance of data processing, caching has become an indispensable part. In PHP development, Redis, as a high-performance key-value storage system, is widely used in caching and data storage scenarios. In order to further improve the experience of using Redis in PHP, PHP8.1 introduces a new Redis extension. This article will introduce the new functions of this extension and provide

What are the new features of go language? What are the new features of go language? Aug 24, 2023 pm 01:36 PM

The new features of go language are: 1. Go module, used to manage the dependencies of Go language projects; 2. Error handling, adding a new error type error, making error handling more flexible and concise; 3. Context package, used Used to transfer request range values ​​between goroutines; 4. Embedding, that is, one structure can be embedded in another structure; 5. Synchronization package, to better control the synchronization and communication between goroutines; 6. Error value, Better distinguish between different types of errors; 7. Generics allow developers to write more flexibly.

See all articles