エントリーの編集
エントリーの編集は全ユーザーに共通の機能です。
必ずガイドラインを一読の上ご利用ください。
- バナー広告なし
- ミュート機能あり
- ダークモード搭載
関連記事
JavaScriptでオブジェクトの型を判別するのにtypeof演算子使うとツラいよね - Qiita
var a = {}, b = [], c = 'hoge', d = new String('hoge'); typeof a; // "object" typeof b; // "objec... var a = {}, b = [], c = 'hoge', d = new String('hoge'); typeof a; // "object" typeof b; // "object" ← ファッ?! typeof c; // "string" typeof d; // "object" ← ファッ?! Object と Array を区別してくれないとかないわー。new String()使うことないけど、区別しちゃうとかないわー。 ということで以前に自分が日本語訳したJavaScript Gardenにも書いてあった方法を使うと 判別が楽になるんじゃないかと。 function is(type, obj) { var clas = Object.prototype.toString.call(obj).slice(8, -1); return obj !== undefin
2013/05/11 リンク