Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
<div></div>
<div></div>
</body>
</html>
 
var DefaultTypes = {
    'undefined': true,
    'boolean': true,
    'number': true,
    'string': true,
    'function': true
};
function typeOf(type) {
    switch (Object.prototype.toString.call(type)) {
        case '[object Array]':
            return 'array';
        case '[object Null]':
            return 'null';
        case '[object Object]':
            return 'object';
        default:
            if (typeof(type) in DefaultTypes) {
                return typeof(type);
            } else if (typeof(type) === 'object' && type.length >= 0 && type[0]) {
                return 'array-like';
            }
    }
}
console.log(typeOf(document.getElementsByTagName('div')));
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
fxslokerpro
0viewers