|
jQuery.isPlainObject(obj)
version 1.4 以降
解説
引数が Object の場合はtrue、そうでない場合はfalseを返します。
つまり、new Object() したものや、オブジェクトリテラルで生成されたものは true になります。
引数
戻り値
-
Boolean: 引数が Object の場合は
true、そうでない場合はfalse
例
例1:様々な引数を指定し、結果を確認します。
$.each([{}, {prop:'aaa'}, true, false, 0, new String(), 'aaa', [], ['aaa']], function(i, value) {
var res = $.isPlainObject(value);
$("#test_result table tr").eq(i++)
.append($("<td>", {css: { "fontWeight": res ? "bold" : "normal" }}).text(res));
});
| $.isPlainObject({}) |
| $.isPlainObject({prop:'aaa'}) |
| $.isPlainObject(true) |
| $.isPlainObject(false) |
| $.isPlainObject(0) |
| $.isPlainObject(new String()) |
| $.isPlainObject('aaa') |
| $.isPlainObject([]) |
| $.isPlainObject(['aaa']) |
|