MooTools: How to define an array of objects?

Is there a shortcut in MooTools to indicate if an object is an object or an array?

+3
source share
3 answers

MooTools is of type $ type () in which you pass the object.

var myString = 'hello';
$type(myString);

Further information can be found at http://mootools.net/docs/core#type

+9
source

Not sure about MooTools, but you can check with Javascript:

var someObject = [];
console.log(someObject instanceof Array) // logs true

But since the array is also an object, you will need to check if it was an array first before checking the object. But using the method $typeis probably easier.

Edit

Mootools $type, :

:

console.log($type("hello"));​​​​​
console.log($type(new Object()));
console.log($type([1, 2, 3]));
​

:

string
object
array

, http://mootools.net/shell/

- http://javascript-reference.info/useful-utility-functions-in-mootools.htm

+2

You can do this using native JavaScript:

Object.prototype.toString.apply(value ) === '[object Array]'

Source: Miller device

+1
source

Source: https://habr.com/ru/post/1730152/


All Articles