# Yahoo! UI Library

### yui 3.3.0

Yahoo! UI Library > yui > Object
Search:
Filters Show Private Show Protected Show Deprecated

## Class Object

Adds the following Object utilities to the YUI instance

### Methods

#### ()

`static Object () ( o )`
Y.Object(o) returns a new object based upon the supplied object.

Parameters:
  `o <object>` the supplier object.

Returns: `Object`
  the new object.

#### _extract

`private static boolean|Array _extract ( o , what )`
Extracts the keys, values, or size from an object

Parameters:
  `o <object>` the object.
  `what <object>` what to extract (0: keys, 1: values, 2: size).

Returns: `boolean|Array`
  the extracted info.

#### each

`static YUI each ( o , f , c , proto )`
Executes a function on each item. The function receives the value, the key, and the object as parameters (in that order).

Parameters:
  `o <object>` the object to iterate.
  `f <Function>` the function to execute on each item. The function receives three arguments: the value, the the key, the full object.
  `c <object>` the execution context.
  `proto <boolean>` include proto.

Returns: `YUI`
  the YUI instance.

#### getValue

`static Any getValue ( o , path )`
Retrieves the sub value at the provided path, from the value object provided.

Parameters:
  `o <object>` The object from which to extract the property value.
  `path <Array>` A path array, specifying the object traversal path from which to obtain the sub value.

Returns: `Any`
  The value stored in the path, undefined if not found, undefined if the source is not an object. Returns the source object if an empty path is provided.

#### hasKey

`static boolean hasKey ( o , k )`
Returns true if the object contains a given key

Parameters:
  `o <object>` an object.
  `k <object>` the key to query.

Returns: `boolean`
  true if the object contains the key.

#### hasValue

`static boolean hasValue ( o , v )`
Returns true if the object contains a given value

Parameters:
  `o <object>` an object.
  `v <object>` the value to query.

Returns: `boolean`
  true if the object contains the value.

#### isEmpty

`static boolean isEmpty ( )`
Returns true if the object has no properties of its own

Returns: `boolean`
  true if the object is empty.

#### keys

`static string[] keys ( o )`
Returns an array containing the object's keys

Parameters:
  `o <object>` an object.

Returns: `string[]`
  the keys.

#### owns

`static boolean owns ( o , p )`
Determines whether or not the property was added to the object instance. Returns false if the property is not present in the object, or was inherited from the prototype.

Parameters:
  `o <any>` The object being testing.
  `p <string>` the property to look for.

Returns: `boolean`
  true if the object has the property on the instance.

#### setValue

`static Object setValue ( o , path , val )`
Sets the sub-attribute value at the provided path on the value object. Returns the modified value object, or undefined if the path is invalid.

Parameters:
  `o <object>` The object on which to set the sub value.
  `path <Array>` A path array, specifying the object traversal path at which to set the sub value.
  `val <Any>` The new value for the sub-attribute.

Returns: `Object`
  The modified object, with the new sub value set, or undefined, if the path was invalid.

#### size

`static int size ( o )`
Returns the size of an object

Parameters:
  `o <object>` an object.

Returns: `int`
  the size.

#### some

`static boolean some ( o , f , c , proto )`
Executes a function on each item, but halts if the function returns true. The function receives the value, the key, and the object as paramters (in that order).

Parameters:
  `o <object>` the object to iterate.
  `f <Function>` the function to execute on each item. The function receives three arguments: the value, the the key, the full object.
  `c <object>` the execution context.
  `proto <boolean>` include proto.

Returns: `boolean`
  true if any execution of the function returns true, false otherwise.

#### values

`static Array values ( o )`
Returns an array containing the object's values

Parameters:
  `o <object>` an object.

Returns: `Array`
  the values.

Copyright © 2011 Yahoo! Inc. All rights reserved.