javascript Objectかどうか判定まとめ
javascriptの場合、ほとんどのクラスがObjectから派生しているため、判定が超めんどくさい。
例えばArrayもオブジェクトになる。
Object.prototype.toString.call(obj)=="[object Object]"
obj instanceof Object && !(obj instanceof Array)
obj instanceof Object && Object.getPrototypeOf(obj) === Object.prototype;
$.isPlainObject(obj)
- lodash
_.isPlainObject(obj)
結論、lodashかjqueryでisPlainObjectを使う
- Javascript オブジェクト判定あれこれ - Mi manca qualche giovedi`?
- javascriptでオブジェクト({ }とか連想配列であるobject)の判定をしたいがnullや配列([ ])に悩まされる問題をまじめに自分用まとめ - tweeeetyのぶろぐ的めも
- Objectかどうかの判定 - hokaccha memo
- [http://stacktrace.jp/jquery/api/utilities/jquery.isplainobject.html
:title]