Javascript 对象的解释


Posted in Javascript onNovember 24, 2008

所有的构造器都是对象,而并非所有的对象都是构造器.每个构造器都有一个用来实现原型继承、共享属性的Prototype属性。对象通过new 表达式创建;比如,new String("A String") 创建了一个String对象。没有通过new而直接调用构造器将有返回值,返回的类型将取决于构造器。例如String("A String")产生一个原始的类型的字符串而不是一个对象。
ECMAScript支持基于原型的继承。每个构造器都有一个与之关联的原型,而且通过此构造器创建的对象都有一个与构造器原型关联的隐式引用(称为,对象的原型)。进一步说,一个原型可能有一个对其原型的非空隐式引用……,这被称为,原型链。当一个引用指向对象的属性,这个引用指向原型链中的第一个对象的以此为名的属性。换句话说,第一次,这个直接关联的对象,将为这个属性被检查。如果这个对象包含以此为名的属性,这个属性就是引用指向的属性。如过这个对象不包含以此为名的属性,那么这个对象的原型将会被继续检查……
原文:
Object
ECMAScript does not contain proper classes such as those in C++, Smalltalk, or Java, but rather,supports constructors which create objects by executing code that allocates storage for the objects and initialises all or part of them by assigning initial values to their properties. All constructors are objects,but not all objects are constructors. Each constructor has a Prototype property that is used to implement prototype-based inheritance and shared properties. Objects are created by using constructors in new expressions; for example, new String("A String") creates a new String object. Invoking a constructor without using new has consequences that depend on the constructor. For example,String("A String") produces a primitive string, not an object.
ECMAScript supports prototype-based inheritance. Every constructor has an associated prototype, and every object created by that constructor has an implicit reference to the prototype (called the object's prototype) associated with its constructor. Furthermore, a prototype may have a non-null implicit reference to its prototype, and so on; this is called the prototype chain. When a reference is made to a property in an object, that reference is to the property of that name in the first object in the prototype chain that contains a property of that name. In other words, first the object mentioned directly is examined for such a property; if that object contains the named property, that is the property to which the reference refers; if that object does not contain the named property, the prototype for that object is examined next; and so on.

Javascript 相关文章推荐
Javascript实例教程(19) 使用HoTMetal(5)
Dec 23 Javascript
超酷的网页音乐播放器DewPlayer使用方法
Dec 18 Javascript
点击隐藏页面左栏或右栏实现js代码
Apr 01 Javascript
JS根据变量保存方法名并执行方法示例
Apr 04 Javascript
js实现的二分查找算法实例
Jan 21 Javascript
JS随机洗牌算法之数组随机排序
Mar 23 Javascript
Javascript json object 与string 相互转换的简单实现
Sep 27 Javascript
Bootstrap整体框架之JavaScript插件架构
Dec 15 Javascript
Bootstrap的modal拖动效果
Dec 25 Javascript
AngularJS与后端php的数据交互方法
Aug 13 Javascript
利用js实现简易红绿灯
Oct 15 Javascript
用几道面试题来看JavaScript执行机制
Apr 30 Javascript
javascript脚本调试方法小结
Nov 24 #Javascript
createElement动态创建HTML对象脚本代码
Nov 24 #Javascript
javascript innerHTML、outerHTML、innerText、outerText的区别
Nov 24 #Javascript
javascript call和apply方法
Nov 24 #Javascript
仿校内登陆框,精美,给那些很厉害但是没有设计天才的程序员
Nov 24 #Javascript
javascript 贪吃蛇实现代码
Nov 22 #Javascript
js利用div背景,做一个竖线的效果。
Nov 22 #Javascript
You might like
PHP创建单例后台进程的方法示例
2017/05/23 PHP
js之WEB开发调试利器:Firebug 下载
2007/01/13 Javascript
javascript 有趣而诡异的数组
2009/04/06 Javascript
js+xml生成级联下拉框代码
2012/07/24 Javascript
js获取height和width的方法说明
2013/01/06 Javascript
ExtJS4中的requires使用方法示例介绍
2013/12/03 Javascript
javascript使用正则获取url上的某个参数
2014/09/04 Javascript
理解Javascript的动态语言特性
2015/06/17 Javascript
js实现表单Radio切换效果的方法
2015/08/17 Javascript
JS实现可调整倒计时间代码分享
2015/08/18 Javascript
Treegrid的动态加载实例代码
2016/04/29 Javascript
基于JavaScript代码实现自动生成表格
2016/06/15 Javascript
利用JQuery操作iframe父页面、子页面的元素和方法汇总
2017/09/10 jQuery
nodejs中安装ghost出错的原因及解决方法
2017/10/23 NodeJs
webpack4打包vue前端多页面项目
2018/09/17 Javascript
jQuery实现获取多选框的值示例
2020/02/07 jQuery
JavaScript的垃圾回收机制与内存管理
2020/08/06 Javascript
JS实现4位随机验证码
2020/10/19 Javascript
[01:31:22]Ti4 循环赛第四日附加赛LGD vs Mouz
2014/07/13 DOTA
TensorFlow实现创建分类器
2018/02/06 Python
pytorch 把MNIST数据集转换成图片和txt的方法
2018/05/20 Python
Sanic框架安装与简单入门示例
2018/07/16 Python
在双python下设置python3为默认的方法
2018/10/31 Python
python实现最大子序和(分治+动态规划)
2019/07/05 Python
Python3环境安装Scrapy爬虫框架过程及常见错误
2019/07/12 Python
Pytorch抽取网络层的Feature Map(Vgg)实例
2019/08/20 Python
Python监听键盘和鼠标事件的示例代码
2020/11/18 Python
CSS3按钮鼠标悬浮实现光圈效果源码
2016/09/11 HTML / CSS
英国IT硬件供应商,定制游戏PC:Mesh Computers
2019/03/28 全球购物
汽车专业人才自我鉴定范文
2013/12/29 职场文书
护士毕业自我鉴定
2014/02/07 职场文书
求职教师自荐书
2014/06/19 职场文书
升学宴演讲稿
2014/09/01 职场文书
毕业生代领毕业材料的授权委托书
2014/09/29 职场文书
社区服务活动感想
2015/08/11 职场文书
Redis字典实现、Hash键冲突及渐进式rehash详解
2021/09/04 Redis