taquaki-satwo
8/27/2018 - 7:10 AM

オブジェクトの判定

JS-オブジェクトの判定

var a = {};
var b = [];
var c = 1;
var d = "string";
var e = false;
var f = undefined;
var g = null;

function isObject(o) {
   return Object.prototype.toString.call(o) === "[object Object]";
}

console.log(isObject(a));
console.log(isObject(b));
console.log(isObject(c));
console.log(isObject(d));
console.log(isObject(e));
console.log(isObject(f));
console.log(isObject(g));

JS-オブジェクトの判定

A Pen by Takaaki Sato on CodePen.

License.