X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/6746dc89c47ed01b165cc1152533605f97eb8e8d..f562e4c6e5fac7bcb445985b99acbea4d706e6f0:/docs/output/Object.js diff --git a/docs/output/Object.js b/docs/output/Object.js new file mode 100644 index 00000000..84edc8f1 --- /dev/null +++ b/docs/output/Object.js @@ -0,0 +1 @@ +Ext.data.JsonP.Object({"tagname":"class","html":"

Files

Creates an object wrapper.

\n\n

The Object constructor creates an object wrapper for the given value. If the value is null or\nundefined, it will create and return an empty object, otherwise, it will return an object of a type\nthat corresponds to the given value.

\n\n

When called in a non-constructor context, Object behaves identically.

\n\n

Using Object given undefined and null types

\n\n

The following examples store an empty Object object in o:

\n\n
var o = new Object();\n\nvar o = new Object(undefined);\n\nvar o = new Object(null);\n
\n\n

Using Object to create Boolean objects

\n\n

The following examples store Boolean objects in o:

\n\n
// equivalent to o = new Boolean(true);\nvar o = new Object(true);\n\n// equivalent to o = new Boolean(false);\nvar o = new Object(Boolean());\n
\n\n
\nDocumentation for this class comes from MDN\nand is available under Creative Commons: Attribution-Sharealike license.\n
\n\n
Defined By

Properties

Specifies the function that creates an object's prototype. ...

Specifies the function that creates an object's prototype.

\n\n

Returns a reference to the Object function that created the instance's prototype. Note that the\nvalue of this property is a reference to the function itself, not a string containing the\nfunction's name, but it isn't read only (except for primitive Boolean, Number or String values: 1,\ntrue, \"read-only\").

\n\n

All objects inherit a constructor property from their prototype:

\n\n
o = new Object // or o = {} in JavaScript 1.2\no.constructor == Object\na = new Array // or a = [] in JavaScript 1.2\na.constructor == Array\nn = new Number(3)\nn.constructor == Number\n
\n\n

Even though you cannot construct most HTML objects, you can do comparisons. For example,

\n\n
document.constructor == Document\ndocument.form3.constructor == Form\n
\n\n

The following example creates a prototype, Tree, and an object of that type, theTree. The example then displays the constructor property for the object theTree.

\n\n
function Tree(name) {\n    this.name = name;\n}\ntheTree = new Tree(\"Redwood\");\nconsole.log(\"theTree.constructor is \" + theTree.constructor);\n
\n\n

This example displays the following output:

\n\n
theTree.constructor is function Tree(name) {\n    this.name = name;\n}\n
\n\n

The following example shows how to modify constructor value of generic objects. Only true, 1 and\n\"test\" variable constructors will not be changed. This example explains that is not always so safe\nto believe in constructor function.

\n\n
function Type(){};\nvar types = [\n    new Array,  [],\nnew Boolean,    true,\nnew Date,\nnew Error,\nnew Function,   function(){},\nMath,\nnew Number, 1,\nnew Object, {},\nnew RegExp, /(?:)/,\nnew String, \"test\"\n];\nfor(var i = 0; i < types.length; i++){\n    types[i].constructor = Type;\n    types[i] = [types[i].constructor, types[i] instanceof Type, types[i].toString()];\n};\nalert(types.join(\"\\n\"));\n
\n
 

Allows the addition of properties to all objects of type Object.

\n

Allows the addition of properties to all objects of type Object.

\n
Defined By

Methods

Creates new Object. ...

Creates new Object.

\n

Parameters

  • value : Object (optional)

    The value to wrap.

    \n

Returns

Returns a boolean indicating whether an object contains the specified property as a direct property\nof that object an...

Returns a boolean indicating whether an object contains the specified property as a direct property\nof that object and not inherited through the prototype chain.

\n\n

Every object descended from Object inherits the hasOwnProperty method. This method can be used\nto determine whether an object has the specified property as a direct property of that object;\nunlike the in operator, this method does not check down the object's prototype chain.

\n\n

The following example determines whether the o object contains a property named prop:

\n\n
o = new Object();\no.prop = 'exists';\n\nfunction changeO() {\n    o.newprop = o.prop;\n    delete o.prop;\n}\n\no.hasOwnProperty('prop');   //returns true\nchangeO();\no.hasOwnProperty('prop');   //returns false\n
\n\n

The following example differentiates between direct properties and properties inherited through the\nprototype chain:

\n\n
o = new Object();\no.prop = 'exists';\no.hasOwnProperty('prop');             // returns true\no.hasOwnProperty('toString');         // returns false\no.hasOwnProperty('hasOwnProperty');   // returns false\n
\n\n

The following example shows how to iterate over the properties of an object without executing on\ninherit properties.

\n\n
var buz = {\n    fog: 'stack'\n};\n\nfor (var name in buz) {\n    if (buz.hasOwnProperty(name)) {\n        alert(\"this is fog (\" + name + \") for sure. Value: \" + buz[name]);\n    }\n    else {\n        alert(name); // toString or something else\n    }\n}\n
\n

Parameters

  • prop : String

    The name of the property to test.

    \n

Returns

  • Boolean

    Returns true if object contains specified property; else\nreturns false.

    \n
Returns a boolean indication whether the specified object is in the prototype chain of the object\nthis method is call...

Returns a boolean indication whether the specified object is in the prototype chain of the object\nthis method is called upon.

\n\n

isPrototypeOf allows you to check whether or not an object exists within another object's\nprototype chain.

\n\n

For example, consider the following prototype chain:

\n\n
function Fee() {\n    // . . .\n}\n\nfunction Fi() {\n    // . . .\n}\nFi.prototype = new Fee();\n\nfunction Fo() {\n    // . . .\n}\nFo.prototype = new Fi();\n\nfunction Fum() {\n    // . . .\n}\nFum.prototype = new Fo();\n
\n\n

Later on down the road, if you instantiate Fum and need to check if Fi's prototype exists\nwithin the Fum prototype chain, you could do this:

\n\n
var fum = new Fum();\n. . .\n\nif (Fi.prototype.isPrototypeOf(fum)) {\n// do something safe\n}\n
\n\n

This, along with the instanceof operator particularly comes in handy if you have code that can\nonly function when dealing with objects descended from a specific prototype chain, e.g., to\nguarantee that certain methods or properties will be present on that object.

\n

Parameters

  • prototype : Object

    an object to be tested against each link in the prototype chain of the\nobject argument

    \n
  • object : Object

    the object whose prototype chain will be searched

    \n

Returns

  • Boolean

    Returns true if object is a prototype and false if not.

    \n
Returns a boolean indicating if the internal ECMAScript DontEnum attribute is set. ...

Returns a boolean indicating if the internal ECMAScript DontEnum attribute is set.

\n\n

Every object has a propertyIsEnumerable method. This method can determine whether the specified\nproperty in an object can be enumerated by a for...in loop, with the exception of properties\ninherited through the prototype chain. If the object does not have the specified property, this\nmethod returns false.

\n\n

The following example shows the use of propertyIsEnumerable on objects and arrays:

\n\n
var o = {};\nvar a = [];\no.prop = 'is enumerable';\na[0] = 'is enumerable';\n\no.propertyIsEnumerable('prop');   // returns true\na.propertyIsEnumerable(0);        // returns true\n
\n\n

The following example demonstrates the enumerability of user-defined versus built-in properties:

\n\n
var a = ['is enumerable'];\n\na.propertyIsEnumerable(0);          // returns true\na.propertyIsEnumerable('length');   // returns false\n\nMath.propertyIsEnumerable('random');   // returns false\nthis.propertyIsEnumerable('Math');     // returns false\n
\n\n

Direct versus inherited properties

\n\n
var a = [];\na.propertyIsEnumerable('constructor');         // returns false\n\nfunction firstConstructor()\n{\n    this.property = 'is not enumerable';\n}\nfirstConstructor.prototype.firstMethod = function () {};\n\nfunction secondConstructor()\n{\n    this.method = function method() { return 'is enumerable'; };\n}\n\nsecondConstructor.prototype = new firstConstructor;\nsecondConstructor.prototype.constructor = secondConstructor;\n\nvar o = new secondConstructor();\no.arbitraryProperty = 'is enumerable';\n\no.propertyIsEnumerable('arbitraryProperty');   // returns true\no.propertyIsEnumerable('method');              // returns true\no.propertyIsEnumerable('property');            // returns false\n\no.property = 'is enumerable';\n\no.propertyIsEnumerable('property');            // returns true\n\n// These return false as they are on the prototype which\n// propertyIsEnumerable does not consider (even though the last two\n// are iteratable with for-in)\no.propertyIsEnumerable('prototype'); // returns false (as of JS 1.8.1/FF3.6)\no.propertyIsEnumerable('constructor'); // returns false\no.propertyIsEnumerable('firstMethod'); // returns false\n
\n

Parameters

  • prop : String

    The name of the property to test.

    \n

Returns

  • Boolean

    If the object does not have the specified property, this\nmethod returns false.

    \n
Returns a string representing the object. ...

Returns a string representing the object. This method is meant to be overridden by derived objects\nfor locale-specific purposes.

\n\n

Object's toLocaleString returns the result of calling toString.

\n\n

This function is provided to give objects a generic toLocaleString method, even though not all\nmay use it. Currently, only Array, Number, and Date override toLocaleString.

\n

Returns

  • String

    Object represented as a string.

    \n
Returns a string representation of the object. ...

Returns a string representation of the object.

\n\n

Every object has a toString() method that is automatically called when the object is to be\nrepresented as a text value or when an object is referred to in a manner in which a string is\nexpected. By default, the toString() method is inherited by every object descended from Object.\nIf this method is not overridden in a custom object, toString() returns \"[object type]\", where\ntype is the object type. The following code illustrates this:

\n\n
var o = new Object();\no.toString();           // returns [object Object]\n
\n\n

You can create a function to be called in place of the default toString() method. The\ntoString() method takes no arguments and should return a string. The toString() method you\ncreate can be any value you want, but it will be most useful if it carries information about the\nobject.

\n\n

The following code defines the Dog object type and creates theDog, an object of type Dog:

\n\n
function Dog(name,breed,color,sex) {\n    this.name=name;\n    this.breed=breed;\n    this.color=color;\n    this.sex=sex;\n}\n\ntheDog = new Dog(\"Gabby\",\"Lab\",\"chocolate\",\"female\");\n
\n\n

If you call the toString() method on this custom object, it returns the default value inherited\nfrom Object:

\n\n
theDog.toString(); //returns [object Object]\n
\n\n

The following code creates and assigns dogToString() to override the default toString() method.\nThis function generates a string containing the name, breed, color, and sex of the object, in the\nform \"property = value;\".

\n\n
Dog.prototype.toString = function dogToString() {\n    var ret = \"Dog \" + this.name + \" is a \" + this.sex + \" \" + this.color + \" \" + this.breed;\n    return ret;\n}\n
\n\n

With the preceding code in place, any time theDog is used in a string context, JavaScript\nautomatically calls the dogToString() function, which returns the following string:

\n\n
Dog Gabby is a female chocolate Lab\n
\n\n

toString() can be used with every object and allows you to get its class. To use the\nObject.prototype.toString() with every object, you need to call Function.prototype.call() or\nFunction.prototype.apply() on it, passing the object you want to inspect as the first parameter\ncalled thisArg.

\n\n
var toString = Object.prototype.toString;\n\ntoString.call(new Date); // [object Date]\ntoString.call(new String); // [object String]\ntoString.call(Math); // [object Math]\n
\n

Returns

  • String

    Object represented as a string.

    \n
Returns the primitive value of the specified object. ...

Returns the primitive value of the specified object.

\n\n

JavaScript calls the valueOf method to convert an object to a primitive value. You rarely need to\ninvoke the valueOf method yourself; JavaScript automatically invokes it when encountering an\nobject where a primitive value is expected.

\n\n

By default, the valueOf method is inherited by every object descended from Object. Every built-\nin core object overrides this method to return an appropriate value. If an object has no primitive\nvalue, valueOf returns the object itself, which is displayed as:

\n\n
[object Object]\n
\n\n

You can use valueOf within your own code to convert a built-in object into a primitive value.\nWhen you create a custom object, you can override Object.valueOf to call a custom method instead\nof the default Object method.

\n\n

You can create a function to be called in place of the default valueOf method. Your function must\ntake no arguments.

\n\n

Suppose you have an object type myNumberType and you want to create a valueOf method for it.\nThe following code assigns a user-defined function to the object's valueOf method:

\n\n
myNumberType.prototype.valueOf = new Function(functionText)\n
\n\n

With the preceding code in place, any time an object of type myNumberType is used in a context\nwhere it is to be represented as a primitive value, JavaScript automatically calls the function\ndefined in the preceding code.

\n\n

An object's valueOf method is usually invoked by JavaScript, but you can invoke it yourself as\nfollows:

\n\n
myNumber.valueOf()\n
\n\n

Note: Objects in string contexts convert via the toString method, which is different from\nString objects converting to string primitives using valueOf. All objects have a string\nconversion, if only \"[object type]\". But many objects do not convert to number, boolean, or\nfunction.

\n

Returns

  • Object

    Returns value of the object or the object itself.

    \n
","allMixins":[],"meta":{},"requires":[],"deprecated":null,"extends":null,"inheritable":false,"static":false,"superclasses":[],"singleton":false,"code_type":"nop","alias":null,"statics":{"property":[],"css_var":[],"css_mixin":[],"cfg":[],"method":[],"event":[]},"subclasses":[],"uses":[],"protected":false,"mixins":[],"members":{"property":[{"tagname":"property","deprecated":null,"static":false,"owner":"Object","template":null,"required":null,"protected":false,"name":"constructor","id":"property-constructor"},{"tagname":"property","deprecated":null,"static":false,"owner":"Object","template":null,"required":null,"protected":false,"name":"prototype","id":"property-prototype"}],"css_var":[],"css_mixin":[],"cfg":[],"method":[{"tagname":"method","deprecated":null,"static":false,"owner":"Object","template":false,"required":null,"protected":false,"name":"constructor","id":"method-constructor"},{"tagname":"method","deprecated":null,"static":false,"owner":"Object","template":false,"required":null,"protected":false,"name":"hasOwnProperty","id":"method-hasOwnProperty"},{"tagname":"method","deprecated":null,"static":false,"owner":"Object","template":false,"required":null,"protected":false,"name":"isPrototypeOf","id":"method-isPrototypeOf"},{"tagname":"method","deprecated":null,"static":false,"owner":"Object","template":false,"required":null,"protected":false,"name":"propertyIsEnumerable","id":"method-propertyIsEnumerable"},{"tagname":"method","deprecated":null,"static":false,"owner":"Object","template":false,"required":null,"protected":false,"name":"toLocaleString","id":"method-toLocaleString"},{"tagname":"method","deprecated":null,"static":false,"owner":"Object","template":false,"required":null,"protected":false,"name":"toString","id":"method-toString"},{"tagname":"method","deprecated":null,"static":false,"owner":"Object","template":false,"required":null,"protected":false,"name":"valueOf","id":"method-valueOf"}],"event":[]},"private":false,"component":false,"name":"Object","alternateClassNames":[],"id":"class-Object","mixedInto":[],"xtypes":{},"files":[{"href":"Object.html#Object","filename":"Object.js"}]}); \ No newline at end of file