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 ...
随机推荐
- sql中用逗号拼接字符串
MSSQL中可以用STUFF函数拼接成字符串. 如: SELECT FieldSomeElse, ( SELECT STUFF(( SELECT ',' + LinkField FROM Detail ...
- 四舍六入五成双银行家算法的 PHP和Javascript实现
四舍六入五成双 http://baike.baidu.com/view/1245064.htm?fr=aladdin 四舍六入五成双是一种比较精确比较科学的计数保留法,是一种数字修约规则. 对于位数很 ...
- 细谈JavaScript中的书写规范
当你有一些感触想写下一些东西的时候,总会发现其实你想写的所有文章都有大牛已经给你写好了,而且写的比你好. https://github.com/ecomfe/spec/blob/master/java ...
- [置顶] Ubuntu 12.04中文输入法的安装
Ubuntu 12.04中文输入法的安装 Ubuntu上的输入法主要有小小输入平台(支持拼音/二笔/五笔等),Fcitx,Ibus,Scim等.其中Scim和Ibus是输入法框架. 在Ubuntu的中 ...
- velocity-字母序号 list
版权声明:本文为博主原创文章,未经博主允许不得转载. [需求] 遍历一个list,同时需要在每个item前面显示字母序号,例如A,B,C,D [代码] #set($zimu = ["A&qu ...
- ACE的安装方法
ACE的安装方法 下载ACE --1 ACE的主页以及下载链接 http://www.cs.wustl.edu/~schmidt/ACE.html 安装ACE --1 将ACE-5.5.tar.g ...
- C++ ORM ODB 入门介绍(二)
目录[-] 1. ODB中的继承类型 2. abstract和polymorphic的区别 3.polymorphic表格 4.早期版本如何实现polymorphic 5.实例 本节主要介绍ODB中的 ...
- RFC 2616
Network Working Group R. Fielding Request for Comments: 2616 UC Irvine Obsoletes: 2068 J. Gettys Cat ...
- windows 下 node 多版本管理工具 - gnvm
最近写了各个构建工具, 开发环境为mac,需要在windows下测试通过: 因为很久不用windows,windows下的node 版本还是 0.10.* 的,因此决定升级node mac 下我使用的 ...
- OpenSSH Client信息泄露和缓冲区溢出漏洞
一.风险简述: 2016年1月14日OpenSSH发布官方公告称,OpenSSH Client 5.4~7.1版本中未公开说明的功能(Roaming)存在信息泄漏和缓冲区溢出漏洞,此漏洞可能导致您通过 ...