Methods
-
<static> array( value ) → {boolean}
Checks if the
value
is an array. -
Parameters
Name Type Description value
* The value to check.
Returns
Examples
// alias the FooGallery.utils.is namespace var _is = FooGallery.utils.is; console.log( _is.array( [] ) ); // => true console.log( _is.array( null ) ); // => false console.log( _is.array( 123 ) ); // => false console.log( _is.array( "" ) ); // => false
Details
-
<static> boolean( value ) → {boolean}
Checks if the
value
is a boolean. -
Parameters
Name Type Description value
* The value to check.
Returns
Examples
// alias the FooGallery.utils.is namespace var _is = FooGallery.utils.is; console.log( _is.boolean( true ) ); // => true console.log( _is.boolean( false ) ); // => true console.log( _is.boolean( "true" ) ); // => false console.log( _is.boolean( "false" ) ); // => false console.log( _is.boolean( 1 ) ); // => false console.log( _is.boolean( 0 ) ); // => false
Details
-
<static> element( value ) → {boolean}
Checks if the
value
is an element. -
Parameters
Name Type Description value
* The value to check.
Returns
Examples
// alias the FooGallery.utils.is namespace var _is = FooGallery.utils.is, // create an element to test el = document.createElement("span"); console.log( _is.element( el ) ); // => true console.log( _is.element( $(el) ) ); // => false console.log( _is.element( null ) ); // => false console.log( _is.element( {} ) ); // => false
Details
-
<static> empty( value ) → {boolean}
Checks if the
value
is empty. -
Description
The following values are considered to be empty by this method:
""
- An empty string0
- 0 as an integer0.0
- 0 as a float[]
- An empty array{}
- An empty object$()
- An empty jQuery objectfalse
null
undefined
Parameters
Name Type Description value
* The value to check.
Returns
Examples
// alias the FooGallery.utils.is namespace var _is = FooGallery.utils.is; console.log( _is.empty( undefined ) ); // => true console.log( _is.empty( null ) ); // => true console.log( _is.empty( 0 ) ); // => true console.log( _is.empty( 0.0 ) ); // => true console.log( _is.empty( "" ) ); // => true console.log( _is.empty( [] ) ); // => true console.log( _is.empty( {} ) ); // => true console.log( _is.empty( 1 ) ); // => false console.log( _is.empty( 0.1 ) ); // => false console.log( _is.empty( "one" ) ); // => false console.log( _is.empty( ["one"] ) ); // => false console.log( _is.empty( { "name": "My Object" } ) ); // => false
Details
-
<static> error( value ) → {boolean}
Checks if the
value
is an error. -
Parameters
Name Type Description value
* The value to check.
Returns
Examples
// alias the FooGallery.utils.is namespace var _is = FooGallery.utils.is, // create some errors to test err1 = new Error("err1"), err2 = new SyntaxError("err2"); console.log( _is.error( err1 ) ); // => true console.log( _is.error( err2 ) ); // => true console.log( _is.error( null ) ); // => false console.log( _is.error( 123 ) ); // => false console.log( _is.error( "" ) ); // => false console.log( _is.error( {} ) ); // => false console.log( _is.error( [] ) ); // => false
Details
-
<static> fn( value ) → {boolean}
Checks if the
value
is a function. -
Parameters
Name Type Description value
* The value to check.
Returns
Examples
// alias the FooGallery.utils.is namespace var _is = FooGallery.utils.is, // create a function to test func = function(){}; console.log( _is.fn( func ) ); // => true console.log( _is.fn( null ) ); // => false console.log( _is.fn( 123 ) ); // => false console.log( _is.fn( "" ) ); // => false
Details
-
<static> hash( value ) → {boolean}
Checks if the
value
is a hash. -
Parameters
Name Type Description value
* The value to check.
Returns
Examples
// alias the FooGallery.utils.is namespace var _is = FooGallery.utils.is; console.log( _is.hash( {"some": "prop"} ) ); // => true console.log( _is.hash( {} ) ); // => true console.log( _is.hash( window ) ); // => false console.log( _is.hash( document ) ); // => false console.log( _is.hash( "" ) ); // => false console.log( _is.hash( 123 ) ); // => false
Details
-
<static> jq( value ) → {boolean}
Checks if the
value
is a jQuery object. -
Parameters
Name Type Description value
* The value to check.
Returns
Examples
// alias the FooGallery.utils.is namespace var _is = FooGallery.utils.is, // create an element to test el = document.createElement("span"); console.log( _is.jq( $(el) ) ); // => true console.log( _is.jq( $() ) ); // => true console.log( _is.jq( el ) ); // => false console.log( _is.jq( {} ) ); // => false console.log( _is.jq( null ) ); // => false console.log( _is.jq( 123 ) ); // => false console.log( _is.jq( "" ) ); // => false
Details
-
<static> number( value ) → {boolean}
Checks if the
value
is a number. -
Parameters
Name Type Description value
* The value to check.
Returns
Examples
// alias the FooGallery.utils.is namespace var _is = FooGallery.utils.is; console.log( _is.number( 123 ) ); // => true console.log( _is.number( undefined ) ); // => false console.log( _is.number( null ) ); // => false console.log( _is.number( "" ) ); // => false
Details
-
<static> object( value ) → {boolean}
Checks if the
value
is an object. -
Parameters
Name Type Description value
* The value to check.
Returns
Examples
// alias the FooGallery.utils.is namespace var _is = FooGallery.utils.is; console.log( _is.object( {"some": "prop"} ) ); // => true console.log( _is.object( {} ) ); // => true console.log( _is.object( window ) ); // => true console.log( _is.object( document ) ); // => true console.log( _is.object( undefined ) ); // => false console.log( _is.object( null ) ); // => false console.log( _is.object( "" ) ); // => false console.log( _is.object( 123 ) ); // => false
Details
-
<static> promise( value ) → {boolean}
Checks if the
value
is a promise. -
Description
This is a simple check to determine if an object is a jQuery promise object. It simply checks the object has a
then
andpromise
function defined.The promise object is created as an object literal inside of
jQuery.Deferred
, it has no prototype, nor any other truly unique properties that could be used to distinguish it.This method should be a little more accurate than the internal jQuery one that simply checks for a
promise
function.Parameters
Name Type Description value
* The object to check.
Returns
Examples
// alias the FooGallery.utils.is namespace var _is = FooGallery.utils.is; console.log( _is.promise( $.Deferred() ) ); // => true console.log( _is.promise( {} ) ); // => false console.log( _is.promise( undefined ) ); // => false console.log( _is.promise( null ) ); // => false console.log( _is.promise( "" ) ); // => false console.log( _is.promise( 123 ) ); // => false
Details
-
<static> size( value ) → {boolean}
Checks if the
value
is a valid CSS length. -
Parameters
Name Type Description value
* The value to check.
Returns
Examples
// alias the FooGallery.utils.is namespace var _is = FooGallery.utils.is; console.log( _is.size( 80 ) ); // => true console.log( _is.size( "80px" ) ); // => true console.log( _is.size( "80em" ) ); // => true console.log( _is.size( "80%" ) ); // => true console.log( _is.size( {} ) ); // => false console.log( _is.size( undefined ) ); // => false console.log( _is.size( null ) ); // => false console.log( _is.size( "" ) ); // => false
Details
-
<static> string( value ) → {boolean}
Checks if the
value
is a string. -
Parameters
Name Type Description value
* The value to check.
Returns
Examples
// alias the FooGallery.utils.is namespace var _is = FooGallery.utils.is; console.log( _is.string( "" ) ); // => true console.log( _is.string( undefined ) ); // => false console.log( _is.string( null ) ); // => false console.log( _is.string( 123 ) ); // => false
Details
-
<static> undef( value ) → {boolean}
Checks if the
value
isundefined
. -
Parameters
Name Type Description value
* The value to check is undefined.
Returns
Examples
// alias the FooGallery.utils.is namespace var _is = FooGallery.utils.is; console.log( _is.undef( undefined ) ); // => true console.log( _is.undef( null ) ); // => false console.log( _is.undef( 123 ) ); // => false console.log( _is.undef( "" ) ); // => false
Details