Pot.Struct.first

{*} Pot.Struct.first ({Object|Array|*} o)

Pot.js で利用可能。 PotLite.js では利用できません。

引数 o の要素のうち最初の値を取得します。

引数 o の持つ要素のうち、最初の値を取得し返します。

Pot.globalize() が適応されている場合、Pot.first() が first() で実行できます。

o の最初の値が返ります。

Pot.debug(Pot.first({a: 1, b: 2, c: 3}));   // 1
Pot.debug(Pot.first({}));                   // undefined
Pot.debug(Pot.first([1, 2, 3, 4, 5]));      // 1
Pot.debug(Pot.first([]));                   // undefined
Pot.debug(Pot.first({a: 'foo', b: 'bar'})); // 'foo'
Pot.debug(Pot.first(new Array(100)));       // undefined
Pot.debug(Pot.first(null));                 // undefined
Pot.debug(Pot.first((void 0)));             // undefined
Pot.debug(Pot.first('hoge'));               // 'h'
Pot.debug(Pot.first(''));                   // ''
Pot.debug(Pot.first(new String('hoge')));   // 'h'
Pot.debug(Pot.first(123));                  // 3
Pot.debug(Pot.first(0));                    // 0
Pot.debug(Pot.first(-123));                 // 3