当前位置:网站首页>JS monitors empty objects and empty references
JS monitors empty objects and empty references
2022-07-03 07:17:00 【darabiuz】
- An empty object : Represents an object , It does not contain any properties and methods
- Null reference : Point to null
Example : Both methods can create an empty object , One is the constructor method , And one is object literal representation
let obj = new Object()
let obj1 = {
}
You can't use null To monitor whether it is an empty object , An empty object does not equal null
Use JSON.stringify==’{}' To detect whether the object is empty , Not recommended

utilize object.keys(obj) Get an array of attributes , If the array length is 0, Description is empty object

obtain obj All attributes of ( Excluding the prototype chain ), It is very similar to the previous method

边栏推荐
猜你喜欢

Interfaces and related concepts

Summary of abnormal mechanism of interview

《指環王:力量之戒》新劇照 力量之戒鑄造者亮相

1. E-commerce tool cefsharp autojs MySQL Alibaba cloud react C RPA automated script, open source log
![[HCAI] learning summary OSI model](/img/90/66505b22e32aa00b26886a9d5c5e4c.jpg)
[HCAI] learning summary OSI model

691. 立方体IV
![[Fiddler problem] solve the problem about Fiddler's packet capturing. After the mobile network is configured with an agent, it cannot access the Internet](/img/9d/42dfef67246740f0dba0c6d8f1b625.jpg)
[Fiddler problem] solve the problem about Fiddler's packet capturing. After the mobile network is configured with an agent, it cannot access the Internet

Recursion, Fibonacci sequence

Selenium key knowledge explanation
![PdfWriter. GetInstance throws system Nullreferenceexception [en] pdfwriter GetInstance throws System. NullRef](/img/65/1f28071fc15e76abb37f1b128e1d90.jpg)
PdfWriter. GetInstance throws system Nullreferenceexception [en] pdfwriter GetInstance throws System. NullRef
随机推荐
Interfaces and related concepts
Unit test notes
2. E-commerce tool cefsharp autojs MySQL Alibaba cloud react C RPA automated script, open source log
Reading notes of "learn to ask questions"
Advanced API (multithreading)
"Baidu Cup" CTF game 2017 February, Web: blast-1
Common analysis with criteria method
TypeScript let與var的區別
《指環王:力量之戒》新劇照 力量之戒鑄造者亮相
Distributed lock
Visit Google homepage to display this page, which cannot be displayed
20220319
Strategy mode
Download address collection of various versions of devaexpress
twenty million two hundred and twenty thousand three hundred and nineteen
CentOS switches and installs mysql5.7 and mysql8.0
Wireshark software usage
【已解决】Unknown error 1146
[Fiddler actual operation] how to use Fiddler to capture packets on Apple Mobile Phones
Hash table, generic