Pot.js で利用可能。 PotLite.js では利用できません。
引数 o が持つ要素数を取得します。
引数 o が持つ要素の数を数えて、その数を返します。
Pot.globalize() が適応されている場合、Pot.count() が count() で実行できます。
要素数が返ります。
Pot.debug(Pot.count({a: 1, b: 2, c: 3})); // 3
Pot.debug(Pot.count({})); // 0
Pot.debug(Pot.count([1, 2, 3, 4, 5])); // 5
Pot.debug(Pot.count([])); // 0
Pot.debug(Pot.count(new Object('foo', 'bar', 'baz'))); // 3
Pot.debug(Pot.count(new Array(100))); // 100
Pot.debug(Pot.count(null)); // 0
Pot.debug(Pot.count((void 0))); // 0
Pot.debug(Pot.count('hoge')); // 4
Pot.debug(Pot.count('')); // 0
Pot.debug(Pot.count(new String('hoge'))); // 4
Pot.debug(Pot.count(100)); // 100
Pot.debug(Pot.count(0)); // 0
Pot.debug(Pot.count(-1)); // 1
Pot.debug(Pot.count((function() {}))); // 0
var f = function() {};
f.foo = 1;
f.bar = 2;
Pot.debug(Pot.count(f)); // 2