Skip to Content
你不知道的JavaScript(下卷)
book

你不知道的JavaScript(下卷)

by Kyle Simpson
January 2018
Intermediate to advanced
286 pages
7h 10m
Chinese
Posts & Telecom Press
Content preview from 你不知道的JavaScript(下卷)
240
7
7.5
 
Reflect
API
Reflect
对象是一个平凡对象(就像
Math
),不像其他内置原生值一样是函数
/
构造器。
它持有对应于各种可控的元编程任务的静态函数。这些函数一对一对应着代理可以定义的
处理函数方法(
trap
)。
这些函数中的一部分看起来和
Object
上的同名函数类似:
Reflect.getOwnPropertyDescriptor(..);
Reflect.defineProperty(..);
Reflect.getPrototypeOf(..);
Reflect.setPrototypeOf(..);
Reflect.preventExtensions(..);
Reflect.isExtensible(..)
一般来说这些工具和
Object.*
的对应工具行为方式类似。但是,有一个区别是如果第一个
参数(目标对象)不是对象的话,
Object.*
相应工具会试图把它类型转换为一个对象。而
这种情况下
Reflect.*
方法只会抛出一个错误。
可以使用下面这些工具访问
/
查看一个对象键:
Reflect.ownKeys(..)
返回所有“拥有”的(不是“继承”的)键的列表,就像
Object.getOwnPropertyNames
(..)
Object.getOwnPropertySymbols(..)
返回的一样。关于键的顺序参见后面的“属
性排序”一节。
Reflect.enumerate(..)
返回一个产生所有(拥有的和“继承的”)
可枚举的
enumerable ...
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

PHP学习手册

PHP学习手册

David Sklar
Web容量规划之美

Web容量规划之美

Arun Kejariwal, John Allspaw
算法精讲视频课程:24篇系列讲座

算法精讲视频课程:24篇系列讲座

罗伯特·塞奇威克, 凯文·韦恩(Kevin Wayne)

Publisher Resources

ISBN: 9787115471659