# Yahoo! UI Library

### yui 3.3.0

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

## `static` Class Lang

Provides the language utilites and extensions used by the library

### Methods

#### isArray

`static boolean isArray ( o )`
Determines whether or not the provided item is an array. Returns false for array-like collections such as the function arguments collection or HTMLElement collection will return false. Use `Y.Array.test` if you want to test for an array-like collection.

Parameters:
  `o <object>` The object to test.

Returns: `boolean`
  true if o is an array.

#### isBoolean

`static boolean isBoolean ( o )`
Determines whether or not the provided item is a boolean.

Parameters:
  `o <object>` The object to test.

Returns: `boolean`
  true if o is a boolean.

#### isDate

`static boolean isDate ( o )`
Determines whether or not the supplied item is a date instance.

Parameters:
  `o <object>` The object to test.

Returns: `boolean`
  true if o is a date.

#### isFunction

`static boolean isFunction ( o )`

Determines whether or not the provided item is a function. Note: Internet Explorer thinks certain functions are objects:

    var obj = document.createElement("object");
    Y.Lang.isFunction(obj.getAttribute) // reports false in IE

    var input = document.createElement("input"); // append to body
    Y.Lang.isFunction(input.focus) // reports false in IE

You will have to implement additional tests if these functions matter to you.

Parameters:
  `o <object>` The object to test.

Returns: `boolean`
  true if o is a function.

#### isNull

`static boolean isNull ( o )`
Determines whether or not the provided item is null.

Parameters:
  `o <object>` The object to test.

Returns: `boolean`
  true if o is null.

#### isNumber

`static boolean isNumber ( o )`
Determines whether or not the provided item is a legal number.

Parameters:
  `o <object>` The object to test.

Returns: `boolean`
  true if o is a number.

#### isObject

`static boolean isObject ( o , failfn )`
Determines whether or not the provided item is of type object or function. Note that arrays are also objects, so `Y.Lang.isObject([]) === true`.

Parameters:
  `o <object>` The object to test.
  `failfn <boolean>` fail if the input is a function.

Returns: `boolean`
  true if o is an object.

#### isString

`static boolean isString ( o )`
Determines whether or not the provided item is a string.

Parameters:
  `o <object>` The object to test.

Returns: `boolean`
  true if o is a string.

#### isUndefined

`static boolean isUndefined ( o )`
Determines whether or not the provided item is undefined.

Parameters:
  `o <object>` The object to test.

Returns: `boolean`
  true if o is undefined.

#### isValue

`static boolean isValue ( o )`
A convenience method for detecting a legitimate non-null value. Returns false for null/undefined/NaN, true for other values, including 0/false/''

Parameters:
  `o <object>` The item to test.

Returns: `boolean`
  true if it is not null/undefined/NaN || false.

#### now

`int now ( )`
Returns the current time in milliseconds.

Returns: `int`
  the current date

#### sub

`static string sub ( s , o )`
Lightweight version of `Y.substitute`. Uses the same template structure as `Y.substitute`, but doesn't support recursion, auto-object coersion, or formats.

Parameters:
  `s <string>` String to be modified.
  `o <object>` Object containing replacement values.

Returns: `string`
  the substitute result.

#### trim

`static string trim ( s )`
Returns a string without any leading or trailing whitespace. If the input is not a string, the input will be returned untouched.

Parameters:
  `s <string>` the string to trim.

Returns: `string`
  the trimmed string.

#### trimLeft

`static string trimLeft ( s )`
Returns a string without any leading whitespace.

Parameters:
  `s <string>` the string to trim.

Returns: `string`
  the trimmed string.

#### trimRight

`static string trimRight ( s )`
Returns a string without any trailing whitespace.

Parameters:
  `s <string>` the string to trim.

Returns: `string`
  the trimmed string.

#### type

`static string type ( o )`

Returns a string representing the type of the item passed in.

Known issues:

- `typeof HTMLElementCollection` returns function in Safari, but `Y.type()` reports object, which could be a good thing -- but it actually caused the logic in `Y.Lang.isObject` to fail.

Parameters:
  `o <object>` the item to test.

Returns: `string`
  the detected type.

Copyright © 2011 Yahoo! Inc. All rights reserved.