1. Trang chủ
  2. » Công Nghệ Thông Tin

javascript programmer''''s reference phần 7 ppt

262 449 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Cấu trúc

  • O

    • Object (Definition)

    • Object (Type)

    • Object constant (Definition)

    • Object inspector (Useful tip)

    • Object literal (Definition)

    • Object model (Definition)

    • Object object (Object/core)

    • Object() (Constructor)

    • Object() (Function)

    • Object.__parent__ (Property)

    • Object.__proto__ (Property)

    • Object.assign() (Method)

    • Object.Class (Property/internal)

    • Object.constructor (Property)

    • Object.eval() (Method)

    • Object.hasOwnProperty() (Method)

    • Object.isPrototypeOf() (Method)

    • Object.name (Property)

    • Object.propertyIsEnumerable() (Method)

    • Object.prototype (Property)

    • Object.toLocaleString() (Method)

    • Object.toSource() (Method)

    • Object.toString() (Method)

    • Object.unwatch() (Method)

    • Object.valueOf() (Method)

    • Object.watch() (Method)

    • Object property delimiter (.) (Delimiter)

    • OBJECT object (Object/HTML)

    • OBJECT.align (Property)

    • OBJECT.altHtml (Property)

    • OBJECT.archive (Property)

    • OBJECT.border (Property)

    • OBJECT.classid (Property)

    • OBJECT.code (Property)

    • OBJECT.codeBase (Property)

    • OBJECT.codeType (Property)

    • OBJECT.data (Property)

    • OBJECT.declare (Property)

    • OBJECT.form (Property)

    • OBJECT.height (Property)

    • OBJECT.hspace (Property)

    • OBJECT.name (Property)

    • OBJECT.object (Property)

    • OBJECT.readyState (Property)

    • OBJECT.standby (Property)

    • OBJECT.tabIndex (Property)

    • OBJECT.type (Property)

    • OBJECT.useMap (Property)

    • OBJECT.vspace (Property)

    • OBJECT.width (Property)

    • Obsolescent (Definition)

    • Octal value (Definition)

    • Off by one errors (Pitfall)

    • Off-screen image caching (Useful tip)

    • offscreenBuffering (Property)

    • OL object (Object/HTML)

    • OL.compact (Property)

    • OL.start (Property)

    • OL.type (Property)

    • on ... (Event handler)

    • onAbort (Event handler)

    • onAfterPrint (Event handler)

    • onAfterUpdate (Event handler)

    • onBack (Event handler)

    • onBeforeCopy (Event handler)

    • onBeforeCut (Event handler)

    • onBeforeEditFocus (Event handler)

    • onBeforePaste (Event handler)

    • onBeforePrint (Event handler)

    • onBeforeUnload (Event handler)

    • onBeforeUpdate (Event handler)

    • onBlur (Event handler)

    • onBounce (Event handler)

    • onChange (Event handler)

    • onClick (Event handler)

    • onContentReady (Event handler)

    • onContextMenu (Event handler)

    • onCopy (Event handler)

    • onCut (Event handler)

    • onDataAvailable (Event handler)

    • onDataSetChanged (Event handler)

    • onDataSetComplete (Event handler)

    • onDblClick (Event handler)

    • onDocumentReady (Event handler)

    • onDrag (Event handler)

    • onDragDrop (Event handler)

    • onDragEnd (Event handler)

    • onDragEnter (Event handler)

    • onDragLeave (Event handler)

    • onDragOver (Event handler)

    • onDragStart (Event handler)

    • onDrop (Event handler)

    • onError (Event handler)

    • onErrorUpdate (Event handler)

    • onFilterChange (Event handler)

    • onFinish (Event handler)

    • onFocus (Event handler)

    • onForward (Event handler)

    • onHelp (Event handler)

    • onKeyDown (Event handler)

    • onKeyPress (Event handler)

    • onKeyUp (Event handler)

    • onLoad (Event handler)

    • onLoseCapture (Event handler)

    • onMouseDown (Event handler)

    • onMouseDrag (Event handler)

    • onMouseMove (Event handler)

    • onMouseOut (Event handler)

    • onMouseOver (Event handler)

    • onMouseUp (Event handler)

    • onMove (Event handler)

    • onPaste (Event handler)

    • onPropertyChange (Event handler)

    • onReadyStateChange (Event handler)

    • onReset (Event handler)

    • onResize (Event handler)

    • onRowEnter (Event handler)

    • onRowExit (Event handler)

    • onRowsDelete (Event handler)

    • onRowsInserted (Event handler)

    • onScroll (Event handler)

    • onSelect (Event handler)

    • onSelectStart (Event handler)

    • onStart (Event handler)

    • onStop (Event handler)

    • onSubmit (Event handler)

    • onUnload (Event handler)

    • open() (Method)

    • opener (Property)

    • OpenTV (TV Set-top Box)

    • Opera (Web browser)

    • Operator (Definition)

    • Operator Precedence (Definition)

    • OptGroupElement object (Object/HTML)

    • OptGroupElement.disabled (Property)

    • OptGroupElement.label (Property)

    • Option object (Object/HTML)

    • Option() (Constructor)

    • Option.defaultSelected (Property)

    • Option.index (Property)

    • Option.label (Property)

    • Option.prototype (Property)

    • Option.selected (Property)

    • Option.text (Property)

    • Option.value (Property)

    • OptionElement object (Object/DOM)

    • OptionsArray object (Object/browser)

    • add() (Method)

    • OptionsArray.item() (Method)

    • OptionsArray.length (Property)

    • OptionsArray.remove() (Method)

    • OptionsArray.select() (Method)

    • outerHeight (Property)

    • outerWidth (Property)

    • Overview (Background)

  • P

    • P object (object/HTML)

    • P.align (Property)

    • pac (File extension)

    • package (Reserved word)

    • Packages (Property)

    • Packages.java (Java package)

    • Packages.netscape (Java package)

    • Packages.netscape.javascript (Java package)

    • Packages.netscape.plugin (Java package)

    • Packages.sun (Java package)

    • pageXOffset (Property)

    • pageYOffset (Property)

    • ParamElement object (Object/HTML)

    • ParamElement.name (Property)

    • ParamElement.type (Property)

    • ParamElement.value (Property)

    • ParamElement.valueType (Property)

    • Parameter (Definition)

    • parent (Property)

    • Parentheses ( ) (Delimiter)

    • parseFloat() (Function/global)

    • parseInt() (Function/global)

    • Password object (Object/DOM)

    • Password.handleEvent() (Method)

    • Password.maxLength (Property)

    • Password.readOnly (Property)

    • Password.select() (Method)

    • Password.size (Property)

    • Password.type (Property)

    • Password.value (Property)

    • Pattern matching (Definition)

    • PDF (Standard)

    • Perl Connect (Product)

    • personalbar (Property)

    • Pitfalls (Advice)

    • Pixelate() (Filter/transition)

    • Pixelate() (Filter/visual)

    • Pkcs11 object (Object/Navigator)

    • PLAINTEXT object (Object/HTML)

    • Platform (Definition)

    • Plugin compatibility issues (Definition)

    • Plugin events (Definition)

    • Plugin object (Object/browser)

    • description (Property)

    • Plugin.filename (Property)

    • Plugin.isActive() (Method)

    • Plugin.length (Property)

    • Plugin.name (Property)

    • Plugin.refresh() (Method)

    • PluginArray object (Object/browser)

    • PluginArray.item() (Method)

    • PluginArray.length (Property)

    • PluginArray.refresh() (Method)

    • Pointers (Overview)

    • Polymorphic (Definition)

    • Portability (Definition)

    • Positive value (+) (Operator/unary)

    • Postfix decrement (--) (Operator/postfix)

    • Postfix expression (Operator/postfix)

    • Postfix increment (++) (Operator/postfix)

    • Postfix operator (Definition)

    • Power function (Definition)

    • PRE object (Object/HTML)

    • PRE.width (Property)

    • Pre-processing (Definition)

    • Pre-processing – /*@ ... @*/ (Delimiter)

    • Pre-processing – @<variable_name> (Pre- processor)

    • Pre-processing – @_alpha (Pre-processor)

    • Pre-processing – @_jscript (Pre-processor)

    • Pre-processing – @_jscript_build (Pre-processor)

    • Pre-processing – @_jscript_version (Pre-processor)

    • Pre-processing – @_mac (Pre-processor)

    • Pre-processing – @_mc680x0 (Pre-processor)

    • Pre-processing – @_PowerPC (Pre-processor)

    • Pre-processing – @_win16 (Pre-processor)

    • Pre-processing – @_win32 (Pre-processor)

    • Pre-processing – @_x86 (Pre-processor)

    • Pre-processing – @cc_on (Pre-processor)

    • Pre-processing – @elif( ... ) ... (Pre-processor)

    • Pre-processing – @else ... (Pre-processor)

    • Pre-processing – @end (Pre-processor)

    • Pre-processing – @if( ... ) ... (Pre-processor)

    • Pre-processing – @set (Pre-processor)

    • Precedence (Definition)

    • Preferences (Definition)

    • preferences.js (Special file)

    • Prefix decrement (--) (Operator/prefix)

    • Prefix expression (Operator/prefix)

    • Prefix increment (++) (Operator/prefix)

    • Prefix operator (Definition)

    • prefs.js (Special file)

    • Primary expression (Definition)

    • Primitive value (Definition)

    • print() (Method)

    • Printing character (Definition)

    • private (Reserved word)

    • PrivilegeManager object (Java class)

    • PrivilegeManager.disablePrivilege() (Method)

    • PrivilegeManager.enablePrivilege() (Method)

    • Privileges (Definition)

    • Procedural surfaces (Definition)

    • Procedure (Definition)

    • ProcessingInstruction object (Object/DOM)

    • ProcessingInstruction.data (Property)

    • ProcessingInstruction.target (Property)

    • Program (Definition)

    • project object (Object/NES)

    • lock() (Method)

    • project.unlock() (Method)

    • prompt() (Method)

    • Property (Definition)

    • Property accessor (Definition)

    • Property attribute (Definition)

    • Property name (Definition)

    • Property value (Definition)

    • protected (Reserved word)

    • Prototype–Based Inheritance (Definition)

    • Prototype chain (Definition)

    • Prototype object (Definition)

    • prototype.constructor (Definition)

    • prototype.toString() (Definition)

    • prototype property (Definition)

    • Proxies (Definition)

    • proxy.pac (Special file)

    • Pseudo-random numbers (Definition)

    • public (Reserved word)

    • Punctuator (Definition)

    • Put() (Function/internal)

    • put() (Method/internal)

    • PutValue() (Function/internal)

  • Q

    • Q object (Object/HTML)

    • Queue manipulation (Useful tip)

    • Quotation mark (" and ') (Delimiter)

  • R

    • R.E. (Definition)

    • RadialWipe() (Filter/transition)

    • RadioButton object (Object/DOM)

    • RadioButton.checked (Property)

    • RadioButton.defaultChecked (Property)

    • RadioButton.handleEvent() (Method)

    • RadioButton.status (Property)

    • RadioButton.type (Property)

    • RadioButton.value (Property)

    • RandomBars() (Filter/transition)

    • RandomDissolve() (Filter/transition)

    • Range error (Definition)

    • RangeError object (Object/core)

    • Raw event (Definition)

    • ReadOnly (Property attribute)

    • Rect object (Object/browser)

    • bottom (Property)

    • Rect.height (Property)

    • Rect.left (Property)

    • Rect.right (Property)

    • Rect.top (Property)

    • Rect.width (Property)

    • Reference (Definition)

    • Reference counting (Definition)

    • ReferenceError object (Object/core)

    • Regex (Definition)

    • RegExp literal (Definition)

    • RegExp object (Object/core)

    • RegExp() (Constructor)

    • RegExp() (Function)

    • RegExp.$_ (Property)

    • RegExp.$n (Property/static)

    • RegExp.compile() (Method)

    • RegExp.constructor (Property)

    • RegExp.exec() (Method)

    • RegExp.global (Property)

    • RegExp.ignoreCase (Property)

    • RegExp.index (Property)

    • RegExp.input (Property/static)

    • RegExp.lastIndex (Property)

    • RegExp.lastMatch (Property/static)

    • RegExp.lastParen (Property/static)

    • RegExp.leftContext (Property/static)

    • RegExp.multiline (Property/static)

    • RegExp.prototype (Property)

    • RegExp.rightContext (Property/static)

    • RegExp.source (Property)

    • RegExp.test() (Method)

    • RegExp.toSource() (Method)

    • RegExp.toString() (Method)

    • RegExp["$&"] (Property)

    • RegExp["$'"] (Property/static)

    • RegExp["$*"] (Property/static)

    • RegExp["$+"] (Property/static)

    • RegExp["$`"] (Property/static)

    • RegExp pattern (Definition)

    • RegExp pattern – alternation (Definition)

    • RegExp pattern – attributes (Definition)

    • RegExp pattern – character class (Definition)

    • RegExp pattern – character literal (Definition)

    • RegExp pattern – extension syntax (Definition)

    • RegExp pattern – grouping (Definition)

    • RegExp pattern – position (Definition)

    • RegExp pattern – references (Definition)

    • RegExp pattern – repetition (Definition)

    • RegExp pattern – sub-patterns (Definition)

    • Regular expression (Definition)

    • Relational expression (Definition)

    • Relational operator (Definition)

    • releaseEvents() (Function)

    • Remainder (%) (Operator/multiplicative)

    • Remainder then assign (%=) (Operator/ assignment)

    • request object (Object/NES)

    • input_name> (Property)

    • request.<urlExtension> (Property)

    • request.agent (Property)

    • request.imageX (Property)

    • request.imageY (Property)

    • request.ip (Property)

    • request.method (Property)

    • request.protocol (Property)

    • Request-response loop (Definition)

    • Requesting privileges (Security related)

    • Reserved Word (Definition)

    • ResetButton object (Object/DOM)

    • ResetButton.handleEvent() (Method)

    • ResetButton.type (Property)

    • ResetButton.value (Property)

    • resizeBy() (Method)

Nội dung

O – Object (Definition) 1569 This is good because it thinks ahead to the possibility of maintenance and tends towards fewer editing errors: if(aCondition) { someCode } while(aCondition) { someCode } for( ) { someCode } If there is any downside to this it is that every balanced pair of braces will create a new execution context. This may slow performance, but on the other hand it can allow locally scoped variables to be created and destroyed at a level that is more granular than a function body. There is also scope for a religious debate on indentation. Three space characters works great (for me). I don't like tabs because if you move the source code to another editor, the indentation can go awry. Space characters for indentation ensure that the source code looks the same in any monospaced editing window and probably looks OK in a word processor too. See also: Flow control, if( ) , while( ) Object (Definition) There is a distinct difference between an object and an Object. We refer to the built-in Object class with a capitalised name. When referring generically to objects of other classes, the word object is all lower case. Therefore we can have an Object object and a String object. Native objects are built-in, host objects are also built in but created outside of the JavaScript core functionality. User-defined objects are not covered here. JavaScript Programmer's Reference 1570 Here is a list of object classes with a note about what sort of object they are and when how they are managed: Class Category Description Array Native A collection of objects in a sequence Boolean Native A logical value container Date Native A date value container Function Native A function code container Global Built-in A container for global properties, methods, and functions Image Hosted Web browser image wrapper Math Built-in A container for math functions Number Native A numeric value Object Native A generic object String Native A sequence of characters Because you might refer to documents in many ways, possibly by means of object properties or as a property belonging to another window, it is not safe to assume that the document property belonging to the Global object the script is attached to is always the document object you are trying to access. Because of this, the object references in the syntax examples assume the object is being referred to via a variable called myDocument or myObject etc. For example, the value myDocument is shown being assigned as a variable from the many alternative sources from which you can obtain a document object reference. Object (Type) A native built-in type. Availability: ECMAScript edition – 2 An Object is an unordered collection of properties. Each property consists of a name, a value and a set of attributes. See also: Alias, Data Type, Definition, Internal Method, Internal Property, Object object, Property, Property attribute, Type Cross-references: ECMA 262 edition 2 – section 8.6 ECMA 262 edition 3 – section 8.6 Wrox Instant JavaScript – page 28 O – Object constant (Definition) 1571 Object constant (Definition) Constant objects. There are some constant objects defined by the standard. A host implementation may provide a few more. Here is a summary of the basic set of constant objects: ❑ Array constructor ❑ Boolean constructor ❑ Date constructor ❑ Function constructor ❑ Global object ❑ Math object ❑ Number constructor ❑ Object constructor ❑ RegExp constructor See also: Array(), Boolean(), Closure(), Constant expression, Date(), Function(), Global object, Math object, Number(), Object literal, Object() Cross-references: Wrox Instant JavaScript – page 28 Object inspector (Useful tip) A debugging tool for inspecting object properties and classes. Here is a small debugging utility that breaks an object down and displays some of its properties. Example code: <! An example for use on Netscape only > <HTML> <HEAD> <SCRIPT> function object_dump(anObject) { document.write("<HR>"); document.write("<TABLE BORDER=1>"); table_row("<B>Item</B>", "<B>Value</B>"); if(typeof anObject != "object") { JavaScript Programmer's Reference 1572 table_row("Value", anObject); table_row("Typeof", typeof(anObject)); } else { table_row("Value", anObject.valueOf()); table_row("String equiv", anObject.toString()); table_row("Typeof", typeof(anObject)); table_row("Class", anObject.constructor.name); table_row("Prototype", anObject.prototype); } document.write("</TABLE>"); document.write("<HR>"); } function table_row(anItem, aName) { document.write("<TR>"); document.write("<TD>"); document.write(anItem); document.write("</TD>"); document.write("<TD>"); document.write(aName); document.write("</TD>"); document.write("</TR>"); } </SCRIPT> </HEAD> <BODY> <SCRIPT> function nest(abc) { test("aa", bb, 100); } function test(aa, bb, cc, dd) { object_dump(aa); object_dump(bb); object_dump(cc); object_dump(arguments.caller.callee.name); object_dump(arguments.callee.constructor.name); } var bb; nest("aa", bb, 100); object_dump(document); </SCRIPT> </BODY> </HTML> See also: Arguments object, Debugging – client side, typeof O – Object literal (Definition) 1573 Object literal (Definition) An object initialiser that creates the object as well. Availability: ECMAScript edition – 3 Property/method value type: Object object JavaScript version 1.2 introduces Object literals. The object is created and returned by the expression. This would normally be assigned to a variable, which effectively names the object. It isn't the object class but it can be copied. Its class is still "Object". Object literals can be nested so that the properties of the topmost object can in fact be object literals themselves. The values assigned to the properties as the object is created can be derived by evaluating a JavaScript expression. You can add as many properties as you care to but you must be careful to keep the nesting properly balanced. The result is an object with the properties containing the values described in the literal expression. Example code: // Create a simple object literal var simple = { prop:100 }; // Create a nested object literal var nested = { reference: { prop:100 } }; // Create a nested object literal with expression derived value var evaluated = { reference: { prop:(Math.random()*100) } }; See also: Object constant, Object.constructor Cross-references: ECMA 262 edition 3 – section – 11.1.5 O'Reilly JavaScript Definitive Guide – page – 45 Object model (Definition) There are several different object models that are realized in JavaScript implementations. In the Netscape and MSIE web browsers, the object models are provided as representations of the document, the browser, event capturing mechanisms, and the style sheet. In addition, some implementations model the environs, the operating system, and the file system. Each of these object models interacts with the others and is a way of representing the tangible real-world objects. JavaScript Programmer's Reference 1574 Although these are generally arranged in a tree-like structure, there are many short cut references that mean you can refer to the same object in a variety of ways. For example the Netscape JavaPackage object can be referred to with the following properties in a Netscape browser: ❑ Netscape ❑ Packages.netscape ❑ window.Packages.netscape Each one refers to an identical object but from the script writer’s point of view, some time can be saved by using the short cuts. Scripts also appear simpler to read. However, the downside is that the object model hierarchy becomes confusing unless you know about the short-cuts. These shortcuts provided for 'so-called' convenience may in fact be exactly the opposite if they are only available on one platform. Using them immediately renders your script non-portable. Object object (Object/core) An object of the class "Object". Availability: ECMAScript edition – 2 JavaScript – 1.1 JScript – 3.0 Internet Explorer – 4.0 Netscape – 3.0 Netscape Enterprise Server 2.0 Opera 3.0 - myObject = new Object() JavaScript syntax: - myObject = Object Object properties: __parent__, __proto__, constructor, name, prototype Object methods: assign(), eval(), hasOwnProperty(), isPrototypeOf(), propertyIsEnumerable(), toLocaleString(), toSource(), toString(), unwatch(), valueOf(), watch() An instance of the class "Object" is created by using the new operator on the Object() constructor. The new object adopts the behavior of the built-in prototype object through the prototype-inheritance mechanisms. All properties and methods of the prototype are available as if they were part of the instance. An Object is a member of the type Object. It is an unordered collection of properties, each of which may contain a primitive value, another object, or a function. The constructor is invoked by the new operator or by calling it as a Constructor function. For example: new String("Some Text"); O – Object object (Object/core) 1575 This will create a new object of the String type. You can invoke the constructor without the new operator but the consequences will depend on the constructor as to what it will yield as a result. In the case of the String data type, the constructor could be invoked like this: String("Some Text"); However, you would get a primitive string as a result from this and not a String object. JavaScript is somewhat forgiving and you may not notice this happening until later on when it becomes important that you have a String object and not a simple string. Because this object is the topmost parent object in the prototype inheritance hierarchy, all other object classes inherit its methods and properties. However, in some cases they will get overridden or nulled out. DOM level 2 adds the following properties: contentDocument Although JavaScript is object-based, it does not support true object-oriented classes such as the ones you find in C++, Smalltalk, Java or Objective C. Instead, it provides Constructor mechanisms, which create objects by allocating space for them in memory and assigning initial values to their properties. All functions, including constructors are themselves objects; however, not all objects are constructors. Each constructor has a Prototype property that is used to facilitate inheritance based on the prototype. It also provides for shared properties, which is similar to but not the same as the Class properties that you find in true object-oriented languages. Externally, the objects in JavaScript exhibit most of the attributes of a class based object oriented system and some commentators argue that this qualifies JavaScript as being a genuine object oriented system. However I think the following points declassify it as a truly object oriented system, meaning that it is an "object like" system: ❑ Global variables and the scope chain mechanism ❑ Prototype based inheritance ❑ Creation of multiple objects and calling them within a single script ❑ Object data is not truly private It’s a close enough call that JavaScript 2.0 may well move it into the class-based object-oriented category at which time the prototype inheritance would be replaced with super-class/sub-class mechanisms and the arguments become null and void. Warnings: ❑ Be very careful not to confuse this generic top-level core object with the object that MSIE instantiates to represent an <OBJECT> tag. MSIE creates OBJECT objects for that purpose but also supports Object objects. For this reason, it may be the case that interpreters cannot become case-insensitive when matching class names. If they did, then it would be impossible to distinguish between Object and OBJECT class names. JavaScript Programmer's Reference 1576 See also: Aggregate type, Array object, Boolean object, Date object, delete, Function object, Math object, Native object, Number object, Object, OBJECT object, Object(), Object(), Object.Class, Object.prototype, String object, userDefined object Property JavaScript JScript N IE Opera NES ECMA Notes __parent__ 1.2 + - 4.0 + - - - - - __proto__ 1.2 + - 4.0 + - - - - - constructor 1.1 + 3.0 + 3.0 + 4.0 + 3.0 + - 2 + - name - 5.5 + - 5.5 + - - - - prototype 1.1 + 3.0 + 3.0 + 4.0 + 3.0 + - 2 + Warning, ReadOnly, DontDelete, DontEnum Method JavaScript JScript N IE Opera NES ECMA Notes assign() 1.1 + - 3.0 + - - - - Warning, Deprecated eval() 1.1 + 3.0 + 3.0 + 4.0 + 3.0 + 2.0 + - Warning, Deprecated hasOwn Property() 1.5 + 5.5 + 6.0 + 5.5 + - - 3 + - isPrototype Of() 1.5 + 5.5 + 6.0 + 5.5 + - - 3 + - propertyIs Enumerable() 1.5 + 5.5 + 6.0 + 5.5 + - - 3 + - toLocale String() 1.5 + 5.5 + 6.0 + 5.5 + - - 3 + Warning toSource() 1.3 + 3.0 + 4.06 + 4.0 + - - - Warning toString() 1.1 + 3.0 + 3.0 + 4.0 + 3.0 + - 2 + - unwatch() 1.2 + - 4.0 + - - 3.0 + - Warning valueOf() 1.1 + 3.0 + 3.0 + 4.0 + 3.0 + 2.0 + 2 + - watch() 1.2 + - 4.0 + - - 3.0 + - Warning Cross-references: ECMA 262 edition 2 – section 4.2.1 ECMA 262 edition 2 – section 4.3.3 ECMA 262 edition 2 – section 10.1.5 ECMA 262 edition 2 – section 15.2 ECMA 262 edition 3 – section 4.2.1 ECMA 262 edition 3 – section 4.3.3 O – Object() (Constructor) 1577 ECMA 262 edition 3 – section 10.1.5 ECMA 262 edition 3 – section 15.2 O'Reilly JavaScript Definitive Guide – page 44 Wrox Instant JavaScript – page 28 Object() (Constructor) An Object object constructor. Availability: ECMAScript edition – 2 JavaScript – 1.1 JScript – 3.0 Internet Explorer – 4.0 Netscape – 3.0 Netscape Enterprise Server 2.0 Opera 3.0 Property/method value type: Object object - new Object - new Object() JavaScript syntax: - new Object(aValue) Argument list: aValue An initial value for the new object When Object is called as part of a new expression, it is a constructor that may create an object instance. There are limitations what is sensible for the new operator to be able to do with the Object constructor. Since the Object is considered to be the highest ancestor of all objects in the prototype inheritance chain, you cannot logically have more than one Object object. Passing other native objects to the Object Constructor implies a type casting from their native object type to the Object type. That's not logical either. The main use of the Object Constructor then is to manufacturer object instantiations from non-object data types. The table summarizes the resulting values from using the Object() constructor with the new operator. Value Result No argument Creates a new empty object null Creates a new empty object undefined Creates a new empty object Boolean Create a new boolean object whose default value is the input value Number Create a new number object whose default value is the input value String Create a new string object whose default value is the input value Native object Return the native object itself Host object Host implementation dependant behavior. Objects are cloned if necessary but some may not be JavaScript Programmer's Reference 1578 Unless you assign the result of the new operation, an object will simply consume memory. You need to store a reference to it at the time it is instantiated. You can do this by assigning it to a variable or a property of another object, passing it in to a function and making sure it gets retained in there, or storing it as an element in an array. Warnings: ❑ You can refer to objects without the parentheses but then you are not referring to a constructor function but to the object itself. The behavior varies between browsers and depends on the kind of object being instantiated and probably depends on whether it is a wrapper for a primitive data type or a more complex aggregated type. ❑ These all appear to create the same kind of object in both MSIE and Netscape myObject = Object(); myNewObject = new Object(); myOtherObject = new Object; These do not: myBoolean = Boolean(); myNewBoolean = new Boolean(); myOtherBoolean = new Boolean; ❑ In the case of the Boolean, Number, and String object types, only the first form will initialize the new object with a value. Placing the result of these examples in document.write() statements illustrates the behavior. You may want to examine the objects returned in more detail by developing an object inspector script. See also: Boolean(), Constructor function, constructor property, Garbage collection, Global object, Memory leak, new, Number(), Object constant, Object object, Object.prototype, Reference counting, String() Cross-references: ECMA 262 edition 2 – section 15.1.1 ECMA 262 edition 2 – section 15.1.3.1 ECMA 262 edition 2 – section 15.2.2.2 ECMA 262 edition 3 – section 15.2.2 [...]... Cross-references: ECMA 262 edition 2 – section 15.1.1 ECMA 262 edition 2 – section 15.1.3.1 ECMA 262 edition 2 – section 15.2.2.2 ECMA 262 edition 3 – section 15.2 1 579 JavaScript Programmer's Reference Object. parent (Property) A special property in which to access the scope chain during function execution Availability: JavaScript – 1.2 Netscape – 4.0 Property/method value type: ScopeChain object JavaScript. .. Cast operator, Object.prototype, toString() Cross-references: ECMA 262 edition 2 – section – 15.2.4.2 ECMA 262 edition 3 – section – 15.2.4.2 15 87 JavaScript Programmer's Reference Object.unwatch() (Method) A method to disable a watch that was set up on a property change Availability: JavaScript – 1.2 Netscape – 4.0 Netscape Enterprise Server – 3.0 JavaScript syntax: N myObject.unwatch() This is inherited... without the JavaScript interpreter complaining but that any value you assign is ignored See also: MIME types 15 97 JavaScript Programmer's Reference OBJECT.data (Property) A URL that points at a file containing data that the OBJECT element can access Availability: DOM level – 1 JavaScript – 1.5 JScript – 3.0 Internet Explorer – 4.0 Netscape – 6.0 Property/method value type: String primitive JavaScript. .. Element object, Node object Web-references: http://www.w3.org/pub/WWW/TR/WD-object.htm 1593 JavaScript Programmer's Reference OBJECT.align (Property) An alignment control for an tag's position with respect to its parent object Availability: DOM level – 1 JavaScript – 1.5 JScript – 3.0 Internet Explorer – 4.0 Netscape – 6.0 Property/method value type: String primitive JavaScript syntax: - myOBJECT.align... returns a true value See also: HasInstance() Cross-references: ECMA 262 edition 3 – section – 15.2.4.6 Object.name (Property) This corresponds to the NAME attribute of the tag that creates the object Availability: JScript – 5.5 Internet Explorer – 5.5 Property/method value type: String primitive JavaScript syntax: IE myObject.name 1583 JavaScript Programmer's Reference Objects are identified either by the... the Boolean true value Cross-references: ECMA 262 edition 3 – section 15.2.4 .7 Object.prototype (Property) The prototype for the Object object, which can be used to extend the interface for all Object objects Availability: ECMAScript edition – 2 JavaScript – 1.1 JScript – 3.0 Internet Explorer – 4.0 Netscape – 3.0 Opera browser – 3.0 Property/method value type: Object object JavaScript syntax: - Object.prototype... 1585 JavaScript Programmer's Reference Property attributes: ReadOnly, DontDelete, DontEnum Cross-references: ECMA 262 edition 2 – section 15.2.3.1 ECMA 262 edition 2 – section 15.2.4 ECMA 262 edition 3 – section 15.2.3.1 Object.toLocaleString() (Method) Returns a string primitive version of the object taking the present locale into account during the translation Availability: ECMAScript edition – 3 JavaScript. .. during construction Availability: JavaScript – 1.2 Netscape – 4.0 Property/method value type: Function object JavaScript syntax: N See also: Lexical scoping, Prototype Based Inheritance, Prototype chain, proto myObject. proto Object.assign() (Method) A deprecated mechanism for intercepting messages sent to objects Availability: JavaScript – 1.1 Netscape – 3.0 Deprecated JavaScript syntax: N myObject.assign()... 100; See also: Object.assign(), Object.unwatch(), unwatch(), watch() 1589 JavaScript Programmer's Reference Object property delimiter (.) (Delimiter) A token to delimit object properties from their object Availability: JavaScript syntax: Argument list: ECMAScript edition – 2 JavaScript – 1.0 JScript – 1.0 Internet Explorer – 3.0 Netscape – 2.0 Netscape Enterprise Server version... DontEnum, Internal Cross-references: ECMA 262 edition 2 – section – 8.6.2 ECMA 262 edition 2 – section – 15.2.2.1 ECMA 262 edition 3 – section – 8.6.2 Object.constructor (Property) A reference to a constructor object Availability: ECMAScript edition – 2 JavaScript – 1.1 JScript – 1.0 Internet Explorer – 3.02 Netscape – 3.0 Opera browser – 3.0 Property/method value type: Object object JavaScript syntax: - . also built in but created outside of the JavaScript core functionality. User-defined objects are not covered here. JavaScript Programmer's Reference 1 570 Here is a list of object classes with. tangible real-world objects. JavaScript Programmer's Reference 1 574 Although these are generally arranged in a tree-like structure, there are many short cut references that mean you can. – Object() (Constructor) 1 577 ECMA 262 edition 3 – section 10.1.5 ECMA 262 edition 3 – section 15.2 O'Reilly JavaScript Definitive Guide – page 44 Wrox Instant JavaScript – page 28 Object()

Ngày đăng: 12/08/2014, 19:21