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 相关文章推荐
picChange 图片切换特效的函数代码
May 06 Javascript
把jquery 的dialog和ztree结合实现步骤
Aug 02 Javascript
jquery的ajax异步请求接收返回json数据实例
Jun 16 Javascript
jQuery实现checkbox全选的方法
Jun 10 Javascript
基于JQuery打造无缝滚动新闻步骤详解
Mar 31 Javascript
JS中使用apply、bind实现为函数或者类传入动态个数的参数
Apr 26 Javascript
javascript实现的上下无缝滚动效果
Sep 19 Javascript
javascript 实现动态侧边栏实例详解
Nov 11 Javascript
详解React 16 中的异常处理
Jul 28 Javascript
vue.js 实现输入框动态添加功能
Jun 25 Javascript
微信小程序基础教程之worker线程的使用方法
Jul 15 Javascript
javascript设计模式 ? 迭代器模式原理与用法实例分析
Apr 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类分享
2014/02/07 PHP
推荐:极酷右键菜单
2006/11/29 Javascript
javascript实现unicode和字符的互相转换
2007/07/18 Javascript
jquery 检测元素是否存在的实例代码
2013/11/19 Javascript
javascript定义变量时带var与不带var的区别分析
2015/01/12 Javascript
Jquery zTree 树控件异步加载操作
2016/02/25 Javascript
使用Bootstrap typeahead插件实现搜索框自动补全的方法
2016/07/07 Javascript
jQuery实现ToolTip元素定位显示功能示例
2016/11/23 Javascript
利用百度地图API获取当前位置信息的实例
2017/11/06 Javascript
jQuery实现的上传图片本地预览效果简单示例
2018/03/29 jQuery
jQuery中常用动画效果函数知识点整理
2018/08/19 jQuery
Vue中的vue-resource示例详解
2018/11/02 Javascript
深入理解Node内建模块和对象
2019/03/12 Javascript
vue组件命名和props命名代码详解
2019/09/01 Javascript
原生JS实现九宫格抽奖
2020/09/13 Javascript
Python简单网络编程示例【客户端与服务端】
2017/05/26 Python
Django REST framework 视图和路由详解
2019/07/19 Python
elasticsearch python 查询的两种方法
2019/08/04 Python
python实现身份证实名认证的方法实例
2019/11/08 Python
Python Gluon参数和模块命名操作教程
2019/12/18 Python
使用css3实现的windows8开机加载动画
2014/12/09 HTML / CSS
有影响力的品牌之家:Our Social Collective
2019/06/08 全球购物
Invicta手表官方商店:百年制表历史的瑞士腕表品牌
2019/09/26 全球购物
介绍一下SQL中union,intersect和minus
2012/04/05 面试题
幼儿教师自我鉴定
2013/11/02 职场文书
电子商务网站的创业计划书
2014/01/05 职场文书
《去年的树》教学反思
2014/04/11 职场文书
园林技术专业求职信
2014/07/28 职场文书
父亲节活动策划方案
2014/08/24 职场文书
缓刑人员思想汇报500字
2014/09/12 职场文书
2014银行授权委托书样本
2014/10/04 职场文书
2014年新教师工作总结
2014/11/08 职场文书
优秀党员推荐材料
2014/12/18 职场文书
2015年基层党建工作汇报材料
2015/06/25 职场文书
2016年秋季运动会通讯稿
2015/11/25 职场文书
在前女友婚礼上,用Python破解了现场的WIFI还把名称改成了
2021/05/28 Python