- 2
- 0
- 约1.11万字
- 约 14页
- 2017-10-07 发布于河南
- 举报
java语言深入编写高级jscript代码(Java language depth written high-level JScript code)
java语言深入编写高级jscript代码(Java language depth written high-level JScript code)
1, create advanced objects
Use constructors to create objects
A constructor is a function call to instantiate and initialize the special type of object. You can call a constructor using the new keyword. A new example of using the constructor is given below.
Var myObject = new (Object); / / create a generic object has no attribute.
Var myBirthday = new Date (1961, 5, 10); / / create a Date object.
Var myCar = new (Car); / / create an object of a user defined, and initialize their properties.
A parameter is passed to the newly created null object by the constructor as a value for a particular this keyword. The constructor then is responsible for performing adaptive initialization for the new object (creating attributes and giving their initial values). When finished, the constructor returns a parameter of the object it constructs.
Write constructors
You can create objects and initialize them by using the new operator in combination with predefined constructors like Object (), Date () and Function (). The powerful feature of object oriented programming is the ability to define custom constructors to create custom objects that are used in scripts. Creates a custom constructor so that you can create objects that have defined properties. Here is an example of a custom function (note the use of the this keyword).
When you call the Circle constructor, give the value of the center point and the radius of the circle (all of these elements are necessary to completely define a unique round object). At the end, the Circle object contains three attributes. Here is how to instantiate a Circle object.
Var aCircle = new Circle (5, 11, 99);
Using prototypes to create objects
When you write a constructor, you can use the properties of a prototype object, which itself is an attribute of all constructors, to create inheritance properties and share methods. The prototype properties and methods will be copied to ea
您可能关注的文档
- 2010—2011福建重要时事(2010 - 2011 important events in Fujian).doc
- 2009金山区初三数学模拟试卷(2009 Jinshan District mathematics simulation paper).doc
- 2010中考题数学(2010 math exam).doc
- 2010年3月计算机等级考试二级vf笔试真题(In March 2010 two computer grade examination questions written VF).doc
- 2009年普通高等学校招生全国统一考试(广东卷)(National unified examination for general institutions of higher learning (Guangdong roll) in 2009).doc
- 2010年中考数学真题分类汇编专题29 尺规作图(In 2010 29 compilation of thematic classification of senior high school entrance examination mathematics exam ruler).doc
- 2010年全国自考基础会计学模拟试卷(七)(2010 national self taught basic accounting simulation paper (seven)).doc
- 2010gaokaoti(2010gaokaoti).doc
- 2010年中考复习整理初一初二思品练习卷(2010 exam review, finishing the first two days of thinking quality exercises).doc
- 2010年广州中考数学模拟试题八(In 2010, Guangzhou high school mathematics simulation test questions eight).doc
- Compass说明书用户手册.pdf
- Jiangsu Longda Super Alloy Co., Ltd. 制度 规定 说明书用户手册.pdf
- Sina三六零安全科技股份有限公司会议资料说明书用户手册.pdf
- Canyuan Futures Co., Ltd. 创元期货 公司治理 说明书用户手册.pdf
- Guangzhou Business School发展团员工作细则说明书用户手册.pdf
- SUJIE制度上说明书用户手册.pdf
- SocialOrganizationWorkPlatform说明书用户手册.pdf
- PZGX品类信息型号信息说明书用户手册.pdf
- 2026年党支部书记党课讲稿汇编.docx
- 个人对照 带头强化政治忠诚、提高政治能力方面存在的不足.docx
原创力文档

文档评论(0)