ECMA5.1中Object.seal()和Object.freeze()的区别
1 Object.seal(O)的调用
When the seal function is called, the following steps are taken:
If Type(O) is not Object throw a TypeError exception.
For each named own property name P of O,
Let desc be the result of calling the [[GetOwnProperty]] internal method of O with P.
If desc.[[Configurable]] is true, set desc.[[Configurable]] to false.
Call the [[DefineOwnProperty]] internal method of O with P, desc, and true as arguments.
Set the [[Extensible]] internal property of O to false.
Return O.
2 Object.freeze(O)的调用
If Type(O) is not Object throw a TypeError exception.
For each named own property name P of O,
Let desc be the result of calling the [[GetOwnProperty]] internal method of O with P.
If IsDataDescriptor(desc) is true, then
If desc.[[Writable]] is true, set desc.[[Writable]] to false.
If desc.[[Configurable]] is true, set desc.[[Configurable]] to false.
Call the [[DefineOwnProperty]] internal method of O with P, desc, and true as arguments.
Set the [[Extensible]] internal property of O to false.
Return O.
这两个函数的区别在于伪代码标记部分,这下是终于搞定这两个函数的区别了。
ECMA5.1中Object.seal()和Object.freeze()的区别的更多相关文章
- js中的Object.seal()与Object.freeze()
关键字:seal, freeze, property descriptor. 1.Object.seal() 参考文档(2)中这样描述: The Object.seal() method seals ...
- ES5 对象的扩展(Object.preventExtensions)、密封(Object.seal)和冻结(Object.freeze)
前面提到 ES5 对象属性描述符,这篇看看对象的扩展.密封和冻结. 扩展对象 Object.preventExtensions Object.isExtensible 密封对象 Object.seal ...
- Object.defineProperty和Object.freeze、Object.seal
目录 一 Object.defineProperty 1.1 用法 1.2 数据描述 1.2.1 value 1.2.2 writable 1.2.3 enumerable 1.2.4 configu ...
- [Javascript] Object.freeze() vs Object.seal()
let person = { firstName: "Zhentian", lastName: "Wan" }; /*Object.freeze() makes ...
- Object.freeze与 Object.seal的区别
Object.freeze()冻结一个对象.不能添加新的属性,不能删除已有属性,不能修改该对象已有属性的可枚举性.可配置性.可写性,以及不能修改已有属性的值.冻结一个对象后该对象的原型也不能被修改. ...
- JavaScript中你所不知道的Object(一)
Object实在是JavaScript中很基础的东西了,在工作中,它只有那么贫瘠的几个用法,让人感觉不过尔尔,但是我们真的了解它吗? 1. 当我们习惯用 var a = { name: 'tarol' ...
- JS 中 原生方法 (四) --- Object
Javascript 中 str. arr.date.obj 等常见的原生方法总结 本文也说主要阐释了 Javascript 中的基础类型和 引用类型的自带方法,那么熟悉的同学又可以绕道了 总是绕道, ...
- javascript中的Function和Object
写的很好,理解了很多,特此转发记录 转自:http://blog.csdn.net/tom_221x/archive/2010/02/22/5316675.aspx 在JavaScript中所有的对象 ...
- ES5特性Object.seal
一个对象在默认状态下: 1,extensible:可扩展(可以添加新的属性) 2,configurable:可配置(可以改变原有属性的特性,比如修改属性的enumerable) Object.seal ...
随机推荐
- SIP SDP RTSP RTP RTCP webrtc
rfc1889 rfc2326 rfc3261 rfc3550 rfc3856 rfc6120. SIP SDP RTSP RTP RTCP,就像他们出现的顺序一样,他们在实际应用中的启用 ...
- mysql均衡负载
一.利用mysql 复制分流查询操作: 利用mysql的主从复制可以有效的分流更新操作和查询操作,具体的实现是一个主服务器,承担更新操作,多台从服务器,承担查询操作,主从之间通过复制实现数据的同步.多 ...
- puppet_list
- 有关window.location 对象
之前在有关location的使用就一种方式给他的href赋值使页面跳转.今天看项目中的代码看到了一个不一样的用法 window.location.href = 'http://' + document ...
- hdoj 2612 Find a way【bfs+队列】
Find a way Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total ...
- bug,不该怕~敢敢test就是了
转载自:http://bbs.itcast.cn/thread-10103-1-1.html 当程序员的经历让我知道了一些关于软件编程的事情.下面的这些事情可能会让朋友们对软件开发感到惊讶: 一个程序 ...
- [Whole Web, Node.js PM2] Loggin with PM2
Add config for app's log and error log for PM2. { "apps": [{ "name": "App1& ...
- 选择 GCD 还是 NSTimer ?
我们常常会延迟某件任务的执行,或者让某件任务周期性的执行.然后也会在某些时候需要取消掉之前延迟执行的任务. 延迟操作的方案一般有三种: 1.NSObject的方法: 2.使用NSTimer的方法: 3 ...
- uedoc 源码解析
思路分析 node 包使用 1. JSON5 2. art-template 3.
- iOS之CAKeyframeAnimation关键帧动画详解
CABasicAnimation算是CAKeyFrameAnimation的 特殊情况,即不考虑中间变换过程,只考虑起始点与目标点就可以了.而CAKeyFrameAnimation则更复杂一些,允许我 ...