Home

Awesome

Ask JS

A JavaScript library to ask basic questions.

How-to

ask.isDefined(foo);

ask.isString('foo');

API

ask.isArray(arr)

Returns true if the given argument is an array, false if it is not.

ask.isArray([1, 2, 3]); // true

ask.isObject(obj)

Returns true if the given argument is an object, false if it is not.

ask.isObject({}); // true

ask.isFunction(fn)

Returns true if the given argument is a function, false if it is not.

ask.isFunction(function(){}); // true

ask.isString(str)

Returns true if the given argument is a string, false if it is not.

ask.isString('Hello World!'); // true

ask.isNumber(num)

Returns true if the given argument is a number, false if it is not.

ask.isNumber(1000); // true

ask.isDate(date)

Returns true if the given argument is a date, false if it is not.

ask.isDate(new Date()); // true

ask.isRegexp(regexp)

Returns true if the given argument is a regular expresion, false if it is not.

ask.isRegexp(new RegExp(foo)); // true

ask.isNull(obj)

Returns true if the given argument is null, false if it is not.

ask.isNull(null); // true

ask.isDefined(obj)

Returns true if the given argument is defined, false if it is not.

ask.isNull(window); // true

ask.isNodeElement(node)

Returns true if the given argument is a node element, false if it is not.

ask.isNodeElement(document.body); // true

ask.hasFocus(node)

Returns true if the given argument has focus, false if it has not.

ask.hasFocus(document); // true

ask.isVisible(node)

Returns true if the given argument is visible into the viewport, false if it is not.

ask.isVisible(document); // true

ask.isEmpty(arr)

Returns true if the given array is empty, false if it is not.

ask.isEmpty([]); // true

ask.hasValue(value, arrĀ | str)

Returns true if the given argument is in a given array or string, false if it is not.

ask.hasValue(2, [1,2,3]); // true

// or

ask.hasValue('World', 'Hello World'); // true

ask.hasProperty(key, obj)

Returns true if a given object has a given key, false if it has not.

ask.hasProperty('foo', {'foo': 'bar'}); // true

Contact

License

Licensed under the MIT license.

Copyright (c) 2013 @pazguille.