Home > Web Front-end > JS Tutorial > Consolidation study notes on basic knowledge of JS objects

Consolidation study notes on basic knowledge of JS objects

hzc
Release: 2020-07-01 09:39:19
forward
1873 people have browsed it

1. Objects have unique identification. Even two objects that are exactly the same are not the same object. (The memory addresses of objects created by js are different)

2. Objects have states. The same object may be in different states (properties of js objects)

3. Objects have behavior. The state of the object may be because His behavior changes (attributes of the js object)

Uniqueness of js objects: highly dynamic, js gives users the ability to modify the state and behavior of the object at runtime

Properties describe the object

数据属性 value writable enumerable configurable
访问属性 get set
Copy after login

Special knowledge points

1.toString();//报错
1 .toString();// 1
(1).toString();//1
Copy after login

Lexical analysis and syntax analysis

Boxing conversion

每一种基本类型 Number String Boolean 再对象中都有对应的类(产生临时的对象)
Copy after login

Unboxing operation

把对象转换成原始类型的值  用于对象与原始类型值对比或者计算
toprimitive(input,preferedType);
过程:
    1、输入原始值 直接返回
    2、输入对象 调用input.valueOf() 如果是原始值 直接返回
    3、调用input.toString() 如果是原始值 直接返回
    4、报错
例如 []+[] = '' ;[]+{} = '[object object]';{}+[]=0 ;+[]=0;
Copy after login

Implicit conversion will have an unboxing process

转换为同等类型
== +
Copy after login

If there is no implicit conversion, there will be an unboxing process

===
Copy after login

Recommended tutorial: "JS Tutorial

The above is the detailed content of Consolidation study notes on basic knowledge of JS objects. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:segmentfault.com
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template