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 相关文章推荐
让广告代码不再影响你的网页加载速度
Jul 07 Javascript
Jquery公告滚动+AJAX后台得到数据
Apr 14 Javascript
幻灯片带网页设计中的20个奇妙应用示例小结
May 27 Javascript
node.js中的url.format方法使用说明
Dec 10 Javascript
JS实现仿FLASH效果的竖排导航代码
Sep 15 Javascript
用户代理字符串userAgent可实现的四个识别
Sep 20 Javascript
jQuery插件pagination实现无刷新分页
May 21 Javascript
百度搜索框智能提示案例jsonp
Nov 28 Javascript
详解webpack babel的配置
Jan 09 Javascript
node 使用 async 控制并发的方法
May 07 Javascript
快速解决angularJS中用post方法时后台拿不到值的问题
Aug 14 Javascript
vue实现前端分页完整代码
Jun 17 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相关资料
2006/10/09 PHP
一组PHP加密解密函数分享
2014/06/05 PHP
php base64 编码与解码实例代码
2017/03/21 PHP
php表单处理操作
2017/11/16 PHP
JavaScript的9个陷阱及评点分析
2008/05/16 Javascript
JS 自动安装exe程序
2008/11/30 Javascript
一步一步教你写一个jQuery的插件教程(Plugin)
2009/09/03 Javascript
jQuery 获取URL的GET参数值的小例子
2013/04/18 Javascript
jcrop基本参数一览
2013/07/16 Javascript
Jquery 动态生成表格示例代码
2013/12/24 Javascript
将页面table内容与样式另存成excel文件的方法
2015/08/05 Javascript
jQuery实现固定在网页顶部的菜单效果代码
2015/09/02 Javascript
jquery实现仿新浪微博带动画效果弹出层代码(可关闭、可拖动)
2015/10/12 Javascript
详解Angular的双向数据绑定(MV-VM)
2016/12/26 Javascript
angular2中router路由跳转navigate的使用与刷新页面问题详解
2017/05/07 Javascript
使用Vue的slot插槽分发父组件内容实现高度复用、更加灵活的组件(推荐)
2018/05/01 Javascript
vue-cli项目中使用echarts图表实例
2018/10/22 Javascript
vue+echarts+datav大屏数据展示及实现中国地图省市县下钻功能
2020/11/16 Javascript
[05:17]DOTA2睡衣妹卖萌求签名 CJ第二天全明星影像
2013/07/28 DOTA
python中使用urllib2获取http请求状态码的代码例子
2014/07/07 Python
Python格式化css文件的方法
2015/03/10 Python
Python简单删除目录下文件以及文件夹的方法
2015/05/27 Python
Python编程中实现迭代器的一些技巧小结
2016/06/21 Python
python中Pycharm 输出中文或打印中文乱码现象的解决办法
2017/06/16 Python
Python随机生成均匀分布在三角形内或者任意多边形内的点
2017/12/14 Python
Sanic框架配置操作分析
2018/07/17 Python
浅谈python3.6的tkinter运行问题
2019/02/22 Python
Python进程间通信Queue消息队列用法分析
2019/05/22 Python
python批量处理txt文件的实例代码
2020/01/13 Python
YesBabyOnline美国:全球性的在线婚纱礼服工厂
2018/05/05 全球购物
英国家庭家具、照明和花园家具购物网站:Furniture123
2018/12/31 全球购物
动漫专业高职生职业生涯规划书
2014/02/15 职场文书
电子专业毕业生自荐信
2014/05/25 职场文书
竞选班干部演讲稿400字
2014/08/20 职场文书
庆国庆活动总结
2014/08/28 职场文书
大学生实习证明
2015/06/16 职场文书