Skip to Content
JavaScript 经典实例:第三版
book

JavaScript 经典实例:第三版

by Adam D. Scott, Matthew MacDonald, Shelley Powers
September 2022
Intermediate to advanced
585 pages
8h 17m
Chinese
China Electric Power Press Ltd.
Content preview from JavaScript 经典实例:第三版
180
7
7
-
1
:查找对象属性的不同方式
方法
返回值
获取可枚
获取不可
获取符号
包括继承
举的属性
枚举的属性
属性
的属性
Object.keys()
属性名称数组
Object.values()
属性值数组
Object.entries()
属性数组构成的数组
每个属性数组中包含属
性的名称和对应的值
Object.getOwnProperty
属性名称数组
Names()
Object.getOwnProperty
属性名称数组
Symbols()
Object.getOwnProperty
属性描述符对象数组
Descriptors()
类似于
defineProperty()
使用的那种
7.7
Reflect.ownKeys()
属性名称数组
for...in
循环
每个属性名称
7.4.4
参考
7.3
节介绍如何使用
in
运算符检查单个属性。
7.5
测试空对象
7.5.1
问题
你想判断一个对象是否为空(没有属性)。
7.5.2
方案
使用
Object.keys()
方法获取属性数组,检查数组的
length
是否为
0
const
blankObject = {};
if
(Object.keys(blankObject).length === 0) {
//
这里的代码将运行,因为该对象中什么也没有
对象
181
}
const
objectWithProperty ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

JavaScript Patterns

JavaScript Patterns

Stoyan Stefanov
JavaScript

JavaScript

David Flanagan
JavaScript

JavaScript

T. J. Crowder

Publisher Resources

ISBN: 9787519869601