YUI 3.x Home -

YUI Library Examples: The YUI Global Object: Check Data Types with Lang

Note: This is YUI 3.x. Looking for YUI 2.x?

The YUI Global Object: Check Data Types with Lang

The YUI Global Object includes several useful type-checking methods in the Lang object. In addition to the 'isXYZ' type check methods, YUI3 includes Y.Lang.type, which returns a string represting the type of the tested object. Click the "Check" button in each row to evaluate the data.

Data isObject isArray isFunction type
null
[] or new Array()
{} or new Object()
function Foo() {}
new Foo()

Type Checking with YUI

Instantiate YUI

Checking types

In this example, we use a few of the type-checking methods available in Lang to test various types of data.

Copyright © 2009 Yahoo! Inc. All rights reserved.

Privacy Policy - Terms of Service - Copyright Policy - Job Openings