_.keys(object) 原文Retrieve all the names of the object’s properties.
object のプロパティ名を全て探索する。
_.keys({one : 1, two : 2, three : 3});
=> ["one", "two", "three"]
_.values(object) 原文Return all of the values of the object’s properties.
object のプロパティの値を全て返す。
_.values({one : 1, two : 2, three : 3});
=> [1, 2, 3]
_.pairs(object) 原文Convert an object into a list of [key, value] pairs.
objectを [key, value] のペアになっているリストに変換する。
_.pairs({one: 1, two: 2, three: 3});
=> [["one", 1], ["two", 2], ["three", 3]]
_.invert(object) 原文Returns a copy of the object where the keys have become the values and the values the keys. For this to work, all of your object’s values should be unique and string serializable.
キーを値に、値をキーにした object のコピーを返す。 この関数が機能するためには、オブジェクトのすべての値がユニークでシリアライズ可能な文字列である必要があります。
_.invert({Moe: "Moses", Larry: "Louis", Curly: "Jerome"});
=> {Moses: "Moe", Louis: "Larry", Jerome: "Curly"};
_.functions(object) Alias: methods 原文Returns a sorted list of the names of every method in an object — that is to say, the name of every function property of the object.
オブジェクトの全てのメソッド名のソートされたリストを返します。 すなわち、オブジェクトの全ての関数のプロパティ名のことです。
_.functions(_);
=> ["all", "any", "bind", "bindAll", "clone", "compact", "compose" ...
_.extend(destination, *sources) 原文Copy all of the properties in the source objects over to the destination object, and return the destination object. It’s in-order, so the last source will override properties of the same name in previous arguments.
source オブジェクトの全プロパティを destination オブジェクトにコピーして、 destination オブジェクトを返します。 整理すると、二つめの引数の source は一つめの引数にある同じ名前のプロパティを上書きします。
_.extend({name : 'moe'}, {age : 50});
=> {name : 'moe', age : 50}
_.pick(object, *keys) 原文Return a copy of the object, filtered to only have values for the whitelisted keys (or array of valid keys).
ホワイトリストとして指定したキー(もしくは有効にするキーの配列)の値だけ持つようにフィルタリングした object のコピーを返します。
_.pick({name : 'moe', age: 50, userid : 'moe1'}, 'name', 'age');
=> {name : 'moe', age : 50}
_.omit(object, *keys) 原文Return a copy of the object, filtered to omit the blacklisted keys (or array of keys).
ブラックリストとして指定したキー(もしくはキーの配列)を省略するようにフィルタリングした object のコピーを返します。
_.omit({name : 'moe', age : 50, userid : 'moe1'}, 'userid');
=> {name : 'moe', age : 50}
_.defaults(object, *defaults) 原文Fill in null and undefined properties in object with values from the defaults objects, and return the object. As soon as the property is filled, further defaults will have no effect.
defaults オブジェクトにある値を object のnullとundefinedのプロパティに挿入し、その object を返します。 プロパティが挿入される際は、 defaults は影響を受けません。
var iceCream = {flavor : "chocolate"};
_.defaults(iceCream, {flavor : "vanilla", sprinkles : "lots"});
=> {flavor : "chocolate", sprinkles : "lots"}
_.clone(object) 原文Create a shallow-copied clone of the object. Any nested objects or arrays will be copied by reference, not duplicated.
object の浅いコピーをしたクローンを作成します。 ネストされたオブジェクトや配列は参照によるコピーで、複製されたものではありません。
_.clone({name : 'moe'});
=> {name : 'moe'};
_.tap(object, interceptor) 原文Invokes interceptor with the object, and then returns object. The primary purpose of this method is to “tap into” a method chain, in order to perform operations on intermediate results within the chain.
object に 割り込み処理 を差し込んでから object を返します。 このメソッドの主な目的は、チェーン内の途中の結果を操作するためにメソッドチェーンを利用することです。
_.chain([1,2,3,200])
.filter(function(num) { return num % 2 == 0; })
.tap(alert)
.map(function(num) { return num * num })
.value();
=> // [2, 200] (alerted)
=> [4, 40000]
_.has(object, key) 原文Does the object contain the given key?
Identical to object.hasOwnProperty(key), but uses a safe reference to the hasOwnProperty function, in case it’s been overridden accidentally.
objectに渡されたキーが含まれているかチェックします。
object.hasOwnProperty(key) と同じですが、誤って上書きされる 場合がある hasOwnProperty 関数への参照を安全に行えます。
_.has({a: 1, b: 2, c: 3}, "b");
=> true
_.isEqual(object, other) 原文Performs an optimized deep comparison between the two objects, to determine if they should be considered equal.
等しいものとするべきかどうか判断するために、2つのオブジェクト間で最適化された深い比較を行います。
var moe = {name : 'moe', luckyNumbers : [13, 27, 34]};
var clone = {name : 'moe', luckyNumbers : [13, 27, 34]};
moe == clone;
=> false
_.isEqual(moe, clone);
=> true
_.isEmpty(object) 原文Returns true if object contains no values.
object に値が含まれていない場合、 true を返します。
_.isEmpty([1, 2, 3]);
=> false
_.isEmpty({});
=> true
_.isElement(object) 原文Returns true if object is a DOM element.
object がDOM要素の場合、 true を返します。
_.isElement(jQuery('body')[0]);
=> true
_.isArray(object) 原文Returns true if object is an Array.
object が配列の場合、 true を返します。
(function(){ return _.isArray(arguments); })();
=> false
_.isArray([1,2,3]);
=> true
_.isObject(value) 原文Returns true if value is an Object. Note that JavaScript arrays and functions are objects, while (normal) strings and numbers are not.
value がオブジェクトの場合、 true を返します。 注:JavaScriptの配列と関数はオブジェクトで、(普通の)文字列や整数はオブジェクトではありません。
_.isObject({});
=> true
_.isObject(1);
=> false
_.isArguments(object) 原文Returns true if object is an Arguments object.
object がArgumentsオブジェクトの場合、 true を返します。
(function(){ return _.isArguments(arguments); })(1, 2, 3);
=> true
_.isArguments([1,2,3]);
=> false
_.isFunction(object) 原文Returns true if object is a Function.
object が関数の場合、 true を返します。
_.isFunction(alert);
=> true
_.isString(object) 原文Returns true if object is a String.
object が文字列の場合、 true を返します。
_.isString("moe");
=> true
_.isNumber(object) 原文Returns true if object is a Number (including NaN).
object が整数(NaN を含む)の場合、 true を返します。
_.isNumber(8.4 * 5);
=> true
_.isFinite(object) 原文Returns true if object is a finite Number.
object が有限数の場合、 true を返します。
_.isFinite(-101);
=> true
_.isFinite(-Infinity);
=> false
_.isBoolean(object) 原文Returns true if object is either true or false.
object が true か false のどちらかの場合、 true を返します。
_.isBoolean(null);
=> false
_.isDate(object) 原文Returns true if object is a Date.
object が日付オブジェクトの場合、 true を返します。
_.isDate(new Date());
=> true
_.isRegExp(object) 原文Returns true if object is a RegExp.
object が正規表現オブジェクトの場合、 true を返します。
_.isRegExp(/moe/);
=> true
_.isNaN(object) 原文Returns true if object is NaN. Note: this is not the same as the native isNaN function, which will also return true if the variable is undefined.
object が NaN の場合、 true を返します。 注:この関数は、変数が undefined の時に true が返される組み込みの isNaN 関数と同じではありません。
_.isNaN(NaN);
=> true
isNaN(undefined);
=> true
_.isNaN(undefined);
=> false
_.isNull(object) 原文Returns true if the value of object is null.
objectの 値 が null の場合、 true を返します。
_.isNull(null);
=> true
_.isNull(undefined);
=> false
_.isUndefined(value) 原文Returns true if value is undefined.
value が undefined の場合、 true を返します。
_.isUndefined(window.missingVariable);
=> true