Microsoft®
JScript Object Object |
Language Reference Version 3
|
Provides functionality common to all JScript objects.
new Object([value])The optional value argument is used if you want to convert a primitive data type (number, Boolean, string, or function) into an object. If omitted, an object with no contents is created.
The Object object is contained in all other JScript objects--all of its methods and properties are available in all other objects. The methods can be redefined in objects you define, and are called by JScript at appropriate times. The toString method is an example of a frequently redefined Object method.In this language reference, the description of each Object method includes both default and object-specific implementation information for the intrinsic JScript objects.
© 1997 by Microsoft Corporation. All rights reserved.
See also:
Everything in JS is an object: Arrays, Functions, everything. Object collect properties which are name-value pairs: Names are strings, values are strings, numbers, booleans, or objects. A function value can work like a class method. Objects can be made by constructors as instantiations of prototype objects. When invoked, a function of the prototype object will have its "this" property is set to point to the constructed object, so it can access properties of the instatiated copy of the prototype object; just like an instance of a class.Public object properties. Properties of a constructed object are public
function Container(param) { this.member = param; } var myContainer = new Container('abc'); //myContainer.member contains 'abc'.
Container.prototype.stamp = function (string) { return this.member + string; } //this could also just replace member's value myContainer.stamp('def') //myContainer.member contains 'abcdef'.Private object properties: Ordinary vars and params of the constructor become private members of constructed objects.
function Container(param) { function dec() { if (secret > 0) { secret -= 1; return true; } else { return false; } } this.member = param; var secret = 3; var that = this; } var myContainer = new Container('abc'); //myContainer.member contains 'abc'. myContainer.dec() //is accesable, and can access secret
//myContainer.secret // is NOT accessable.By convention, we make a private that variable. This is used to make the object available to the private methods. This is a workaround for an error in the ECMAScript Language Specification which causes this to be set incorrectly for inner functions.
file: /Techref/inet/iis/jscript/htm/js592.htm, 5KB, , updated: 2022/8/21 15:56, local time: 2024/12/12 19:49,
3.16.70.247:LOG IN
|
©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://sxlist.com/TECHREF/inet/iis/jscript/htm/js592.htm"> Object Object</A> |
Did you find what you needed? |
Welcome to sxlist.com!sales, advertizing, & kind contributors just like you! Please don't rip/copy (here's why Copies of the site on CD are available at minimal cost. |
Welcome to sxlist.com! |
.