国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

characters

_.attempt(func, args)

嘗試調(diào)用func,返回結(jié)果或捕獲的錯(cuò)誤對(duì)象。func調(diào)用時(shí)會(huì)提供任何其他參數(shù)。

版本

3.0.0

參數(shù)
  1. func (功能):嘗試的功能。

  2. [args] (... *):用來(lái)調(diào)用的參數(shù)func

返回

(*):返回func結(jié)果或錯(cuò)誤對(duì)象。

// Avoid throwing errors for invalid selectors.
var elements = _.attempt(function(selector) {  return document.querySelectorAll(selector);}, '>_>'); 
if (_.isError(elements)) {
  elements = [];}

_.bindAll(object, methodNames)

將對(duì)象的方法綁定到對(duì)象本身,覆蓋現(xiàn)有的方法。

注意:此方法不會(huì)設(shè)置綁定函數(shù)的“l(fā)ength”屬性。

以來(lái)

0.1.0

參數(shù)
  1. object (Object):綁定的對(duì)象并將綁定的方法分配給。

  2. methodNames (...(string | string [])):要綁定的對(duì)象方法名稱(chēng)。

Returns

(對(duì)象):返回object。

var view = {  'label': 'docs',  'click': function() {
    console.log('clicked ' + this.label);  }};
 _.bindAll(view, ['click']);jQuery(element).on('click', view.click);// => Logs 'clicked docs' when clicked.

_.cond(pairs)

創(chuàng)建一個(gè)迭代pairs并調(diào)用第一個(gè)謂詞的相應(yīng)函數(shù)來(lái)返回truthy的函數(shù)。謂詞函數(shù)對(duì)this通過(guò)創(chuàng)建的函數(shù)的綁定和參數(shù)來(lái)調(diào)用。

以來(lái)

4.0.0

參數(shù)
  1. pairs (數(shù)組):謂詞函數(shù)對(duì)。

返回

(功能):返回新的復(fù)合功能。

var func = _.cond([  [_.matches({ 'a': 1 }),
_.constant('matches A')],  [_.conforms({ 'b': _.isNumber }), 
_.constant('matches B')],  [_.stubTrue,_.constant('no match')]]); 
func({ 'a': 1, 'b': 2 });
// => 'matches A' func({ 'a': 0, 'b': 1 });
// => 'matches B' func({ 'a': '1', 'b': '2' });
// => 'no match'

_.conforms(source)

創(chuàng)建一個(gè)函數(shù),該函數(shù)source使用給定對(duì)象的相應(yīng)屬性值調(diào)用謂詞屬性,true如果所有謂詞都返回truthy,則返回else      false

注意:所創(chuàng)建的功能相當(dāng)于_.conformsTo     與source部分地施加。

以來(lái)

4.0.0

參數(shù)
  1. source (Object):屬性謂詞符合的對(duì)象。

返回

(功能):返回新的規(guī)格功能。

var objects = [  { 'a': 2, 'b': 1 },  { 'a': 1, 'b': 2 }];
 _.filter(objects, _.conforms({ 'b': function(n) { return n > 1; } }));
 // => [{ 'a': 1, 'b': 2 }]

_.constant(value)

創(chuàng)建一個(gè)返回的函數(shù)value。

以來(lái)

2.4.0

參數(shù)
  1. value (*):從新函數(shù)返回的值。

返回

(函數(shù)):返回新的常量函數(shù)。

var objects = _.times(2, _.constant({ 'a': 1 }));
 console.log(objects);// => [{ 'a': 1 }, { 'a': 1 }]
 console.log(objects[0] === objects[1]);// => true

_.defaultTo(value, defaultValue)

檢查value以確定是否應(yīng)該在其位置返回默認(rèn)值。將defaultValue     返回如果valueNaNnullundefined。

以來(lái)

4.14.0

參數(shù)
  1. value (*):要檢查的值。

  2. defaultValue (*):默認(rèn)值。

返回

(*):返回已解析的值。

_.defaultTo(1, 10);// => 1
 _.defaultTo(undefined, 10);// => 10

_.flow(funcs)

創(chuàng)建一個(gè)函數(shù),該函數(shù)返回調(diào)用給定函數(shù)的結(jié)果this并創(chuàng)建函數(shù)的綁定,其中每個(gè)連續(xù)調(diào)用都提供前一個(gè)函數(shù)的返回值。

以來(lái)

3.0.0

參數(shù)
  1. [funcs] (...(Function | Function [])):要調(diào)用的函數(shù)。

返回

(功能):返回新的復(fù)合功能。

function square(n) {  return n * n;} 
var addSquare = _.flow([_.add, square]);
addSquare(1, 2);// => 9

_.flowRight(funcs)

這個(gè)方法就像_.flow是它創(chuàng)建一個(gè)從右到左調(diào)用給定函數(shù)的函數(shù)。

以來(lái)

3.0.0

參數(shù)
  1. [funcs] (...(Function | Function [])):要調(diào)用的函數(shù)。

返回

(功能):返回新的復(fù)合功能。

function square(n) {  return n * n;} 
var addSquare = _.flowRight([square, _.add]);
addSquare(1, 2);// => 9

_.identity(value)

這個(gè)方法返回它接收到的第一個(gè)參數(shù)。

以來(lái)

0.1.0

參數(shù)
  1. value (*):任何值。

返回

(*):返回value。

var object = { 'a': 1 };
 console.log(_.identity(object) === object);// => true

_.iteratee(func=_.identity)

創(chuàng)建一個(gè)調(diào)用func所創(chuàng)建函數(shù)的參數(shù)的函數(shù)。如果func是屬性名稱(chēng),則創(chuàng)建的函數(shù)將返回給定元素的屬性值。如果func是數(shù)組或?qū)ο螅瑒t創(chuàng)建的函數(shù)將返回true包含等效源屬性的元素,否則返回false。

以來(lái)

4.0.0

參數(shù)
  1. [func=_.identity] (*):轉(zhuǎn)換為回調(diào)的值。

返回

(功能):返回回調(diào)。

var users = [  { 'user': 'barney', 'age': 36, 'active': true },  { 'user': 'fred',   'age': 40, 'active': false }]; 
// The `_.matches` iteratee shorthand.
_.filter(users, _.iteratee({ 'user': 'barney', 'active': true }));
// => [{ 'user': 'barney', 'age': 36, 'active': true }] 
// The `_.matchesProperty` iteratee shorthand.
_.filter(users, _.iteratee(['user', 'fred']));
// => [{ 'user': 'fred', 'age': 40 }] 
// The `_.property` iteratee shorthand.
_.map(users, _.iteratee('user'));// => ['barney', 'fred'] 
// Create custom iteratee shorthands.
_.iteratee = _.wrap(_.iteratee, function(iteratee, func) {  return !_.isRegExp(func) ? iteratee(func) : 
function(string) {    return func.test(string);  };});
 _.filter(['abc', 'def'], /ef/);// => ['def']

_.matches(source)

創(chuàng)建一個(gè)函數(shù),用于在給定對(duì)象之間執(zhí)行部分深層比較source,      true如果給定對(duì)象具有等效屬性值,則返回其他值      false。

注意:所創(chuàng)建的功能相當(dāng)于_.isMatch     與source部分地施加。

部分比較將分別將空數(shù)組和空對(duì)象source值與任何數(shù)組或?qū)ο笾灯ヅ?     。請(qǐng)參閱_.isEqual支持的值比較列表。

以來(lái)

3.0.0

參數(shù)
  1. source (Object):要匹配的屬性值的對(duì)象。

返回

(功能):返回新的規(guī)格功能。

var objects = [  { 'a': 1, 'b': 2, 'c': 3 },  { 'a': 4, 'b': 5, 'c': 6 }];
 _.filter(objects, _.matches({ 'a': 4, 'c': 6 }));// => [{ 'a': 4, 'b': 5, 'c': 6 }]

_.matchesProperty(path, srcValue)

創(chuàng)建一個(gè)函數(shù),用于在path給定對(duì)象的at值處執(zhí)行部分深層比較srcValuetrue如果對(duì)象值相等,則返回else      false

注:部分比較將分別將空數(shù)組和空對(duì)象srcValue     值與任何數(shù)組或?qū)ο笾灯ヅ?。?qǐng)參閱_.isEqual支持的值比較列表。

以來(lái)

3.2.0

參數(shù)
  1. path (Array | string):要獲取的屬性的路徑。

  2. srcValue (*):要匹配的值。

返回

(功能):返回新的規(guī)格功能。

var objects = [  { 'a': 1, 'b': 2, 'c': 3 },  { 'a': 4, 'b': 5, 'c': 6 }];
 _.find(objects, _.matchesProperty('a', 4));// => { 'a': 4, 'b': 5, 'c': 6 }

_.method(path, args)

創(chuàng)建一個(gè)調(diào)用path給定對(duì)象的方法的函數(shù)。任何額外的參數(shù)被提供給被調(diào)用的方法。

以來(lái)

3.7.0

參數(shù)
  1. path (Array | string):要調(diào)用的方法的路徑。

  2. [args] (... *):用來(lái)調(diào)用方法的參數(shù)。

返回

(函數(shù)):返回新的調(diào)用函數(shù)。

var objects = [  { 'a': { 'b': _.constant(2) } },  { 'a': { 'b': _.constant(1) } }];
 _.map(objects, _.method('a.b'));// => [2, 1]
 _.map(objects, _.method(['a', 'b']));// => [2, 1]

_.methodOf(object, args)

與之相反_.method; 這個(gè)方法創(chuàng)建一個(gè)函數(shù)調(diào)用給定路徑的方法object。任何額外的參數(shù)被提供給被調(diào)用的方法。

以來(lái)

3.7.0

參數(shù)
  1. object (Object):要查詢(xún)的對(duì)象。

  2. [args] (... *):用來(lái)調(diào)用方法的參數(shù)。

返回

(函數(shù)):返回新的調(diào)用函數(shù)。

var array = _.times(3, _.constant),

    object = { 'a': array, 'b': array, 'c': array };
 _.map(['a[2]', 'c[0]'], _.methodOf(object));// => [2, 0]
 _.map([['a', '2'], ['c', '0']], _.methodOf(object));// => [2, 0]

_.mixin(object=lodash, source, options={})

將源對(duì)象的所有可枚舉字符串鍵控函數(shù)屬性添加到目標(biāo)對(duì)象。如果object     是一個(gè)函數(shù),那么方法也會(huì)添加到它的原型中。

注意:使用_.runInContext創(chuàng)造一個(gè)純凈的lodash功能,以避免因修改原始的沖突。

以來(lái)

0.1.0

參數(shù)
  1. [object=lodash] (函數(shù)|對(duì)象):目標(biāo)對(duì)象。

  2. source (Object):要添加的函數(shù)的對(duì)象。

  3. [options={}] (對(duì)象):選項(xiàng)對(duì)象。

  4. [options.chain=true] (boolean):指定mixin是否可鏈接。

返回

(*):返回object。

function vowels(string) {  return _.filter(string, function(v) {    return /[aeiou]/i.test(v);  });}
 _.mixin({ 'vowels': vowels });_.vowels('fred');// => ['e'] _('fred').vowels().value();// => ['e']
 _.mixin({ 'vowels': vowels }, { 'chain': false });_('fred').vowels();// => ['e']

_.noConflict()

_變量恢復(fù)為其先前的值并返回對(duì)該lodash     函數(shù)的引用。

以來(lái)

0.1.0

返回

(功能):返回lodash功能。

var lodash = _.noConflict();

_.noop()

此方法返回undefined。

以來(lái)

2.3.0

_.times(2, _.noop);// => [undefined, undefined]

_.nthArg(n=0)

創(chuàng)建一個(gè)在索引處獲取參數(shù)的函數(shù)n。如果n是負(fù)數(shù),則返回從結(jié)尾開(kāi)始的第n個(gè)參數(shù)。

以來(lái)

4.0.0

參數(shù)
  1. [n=0] (數(shù)字):返回參數(shù)的索引。

返回

(功能):返回新的傳遞函數(shù)。

var func = _.nthArg(1);func('a', 'b', 'c', 'd');// => 'b' var func = _.nthArg(-2);func('a', 'b', 'c', 'd');// => 'c'

_.over([iteratees=_.identity])

創(chuàng)建一個(gè)函數(shù),iteratees用它接收的參數(shù)調(diào)用并返回它們的結(jié)果。

以來(lái)

4.0.0

參數(shù)
  1. [iteratees=[_.identity]] (...(Function | Function [])):要調(diào)用的迭代。

返回

(功能):返回新功能。

var func = _.over([Math.max, Math.min]); func(1, 2, 3, 4);// => [4, 1]

_.overEvery([predicates=_.identity])

如果創(chuàng)建一個(gè)檢查函數(shù)所有的的predicates時(shí)候用它接收到的參數(shù)調(diào)用返回truthy。

以來(lái)

4.0.0

參數(shù)
  1. [predicates=[_.identity]] (...(Function | Function [])):要檢查的謂詞。

返回

(功能):返回新功能。

var func = _.overEvery([Boolean, isFinite]); func('1');// => true func(null);// => false func(NaN);// => false

_.overSome([predicates=_.identity])

如果創(chuàng)建一個(gè)檢查功能的任何的的predicates時(shí)候用它接收到的參數(shù)調(diào)用返回truthy。

以來(lái)

4.0.0

參數(shù)
  1. [predicates=[_.identity]] (...(Function | Function [])):要檢查的謂詞。

返回

(功能):返回新功能。

var func = _.overSome([Boolean, isFinite]); func('1');// => true func(null);// => true func(NaN);// => false

_.property(path)

創(chuàng)建一個(gè)返回path給定對(duì)象的值的函數(shù)。

以來(lái)

2.4.0

參數(shù)
  1. path (Array | string):要獲取的屬性的路徑。

返回

(函數(shù)):返回新的存取函數(shù)。

var objects = [  { 'a': { 'b': 2 } },  { 'a': { 'b': 1 } }];
 _.map(objects, _.property('a.b'));// => [2, 1]
 _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');// => [1, 2]

_.propertyOf(object)

與之相反_.property; 這個(gè)方法創(chuàng)建一個(gè)函數(shù),返回給定路徑的值object

以來(lái)

3.0.0

參數(shù)
  1. object (Object):要查詢(xún)的對(duì)象。

返回

(函數(shù)):返回新的存取函數(shù)。

var array = [0, 1, 2],

    object = { 'a': array, 'b': array, 'c': array };
 _.map(['a[2]', 'c[0]'], _.propertyOf(object));// => [2, 0]
 _.map([['a', '2'], ['c', '0']], _.propertyOf(object));// => [2, 0]

_.range(start=0, end, step=1)

創(chuàng)建一個(gè)從最高到但不包括的數(shù)字(正數(shù)和/或負(fù)數(shù))。如果在沒(méi)有or的情況下指定否定,則使用步驟。如果未指定,則設(shè)置為,      然后設(shè)置為。startend-1startendstependstartstart0

注意: JavaScript遵循IEEE-754標(biāo)準(zhǔn)來(lái)解決可能產(chǎn)生意外結(jié)果的浮點(diǎn)值。

以來(lái)

0.1.0

參數(shù)
  1. [start=0] (數(shù)字):范圍的開(kāi)始。

  2. end (數(shù)字):范圍的結(jié)尾。

  3. [step=1] (數(shù)字):通過(guò)增加或減少的值。

返回

(數(shù)組):返回?cái)?shù)字的范圍。

_.range(4);// => [0, 1, 2, 3]
 _.range(-4);// => [0, -1, -2, -3]
 _.range(1, 5);// => [1, 2, 3, 4]
 _.range(0, 20, 5);// => [0, 5, 10, 15]
 _.range(0, -4, -1);// => [0, -1, -2, -3]
 _.range(1, 4, 0);// => [1, 1, 1]
 _.range(0);// => []

_.rangeRight(start=0, end, step=1)

這種方法就像_.range它以降序的方式填充值。

以來(lái)

4.0.0

參數(shù)
  1. [start=0] (數(shù)字):范圍的開(kāi)始。

  2. end (數(shù)字):范圍的結(jié)尾。

  3. [step=1] (數(shù)字):通過(guò)增加或減少的值。

返回

(數(shù)組):返回?cái)?shù)字的范圍。

Example
_.rangeRight(4);// => [3, 2, 1, 0]
 _.rangeRight(-4);// => [-3, -2, -1, 0]
 _.rangeRight(1, 5);// => [4, 3, 2, 1]
 _.rangeRight(0, 20, 5);// => [15, 10, 5, 0]
 _.rangeRight(0, -4, -1);// => [-3, -2, -1, 0]
 _.rangeRight(1, 4, 0);// => [1, 1, 1]
 _.rangeRight(0);// => []

_.runInContext(context=root)

lodash使用該context對(duì)象創(chuàng)建一個(gè)新的原始功能。

以來(lái)

1.1.0

參數(shù)
  1. [context=root] (Object):上下文對(duì)象。

返回

(功能):返回一個(gè)新lodash功能。

_.mixin({ 'foo': _.constant('foo') }); 
var lodash = _.runInContext();lodash.mixin({ 'bar': lodash.constant('bar') });
 _.isFunction(_.foo);// => true_.isFunction(_.bar);// => false
 lodash.isFunction(lodash.foo);
 // => falselodash.isFunction(lodash.bar);
 // => true 
 // Create a suped-up `defer` in Node.js.var defer = _.runInContext({ 'setTimeout': setImmediate }).defer;

_.stubArray()

此方法返回一個(gè)新的空數(shù)組。

以來(lái)

4.13.0

返回

(數(shù)組):返回新的空數(shù)組。

var arrays = _.times(2, _.stubArray);
 console.log(arrays);// => [[], []]
 console.log(arrays[0] === arrays[1]);// => false

_.stubFalse()

此方法返回false。

以來(lái)

4.13.0

返回

(布爾):返回false

_.times(2, _.stubFalse);// => [false, false]

_.stubObject()

此方法返回一個(gè)新的空對(duì)象。

以來(lái)

4.13.0

返回

(Object):返回新的空對(duì)象。

var objects = _.times(2, _.stubObject);
 console.log(objects);// => [{}, {}]
 console.log(objects[0] === objects[1]);// => false

_.stubString()

這個(gè)方法返回一個(gè)空字符串。

以來(lái)

4.13.0

返回

(字符串):返回空字符串。

_.times(2, _.stubString);// => ['', '']

_.stubTrue()

此方法返回true。

以來(lái)

4.13.0

返回

(布爾):返回true

_.times(2, _.stubTrue);// => [true, true]

_.times(n, iteratee=_.identity)

調(diào)用迭代n次數(shù),返回每個(gè)調(diào)用結(jié)果的數(shù)組。迭代器被調(diào)用一個(gè)參數(shù); (指數(shù))。

以來(lái)

0.1.0

參數(shù)
  1. n (數(shù)字):調(diào)用的次數(shù)iteratee。

  2. [iteratee=_.identity] (Function):每次迭代調(diào)用的函數(shù)。

返回

(數(shù)組):返回結(jié)果數(shù)組。

_.times(3, String);// => ['0', '1', '2']
 
 _.times(4, _.constant(0));// => [0, 0, 0, 0]

_.toPath(value)

轉(zhuǎn)換value為屬性路徑數(shù)組。

以來(lái)

4.0.0

參數(shù)
  1. value (*):要轉(zhuǎn)換的值。

返回

(Array):返回新的屬性路徑數(shù)組。

_.toPath('a.b.c');// => ['a', 'b', 'c']
 _.toPath('a[0].b.c');// => ['a', '0', 'b', 'c']

_.uniqueId(prefix='')

生成一個(gè)唯一的ID。如果prefix給出,則ID附加到它。

以來(lái)

0.1.0

參數(shù)
  1. [prefix=''] (字符串):用ID作為ID前綴的值。

返回

(字符串):返回唯一的ID。

_.uniqueId('contact_');// => 'contact_104'
 _.uniqueId();// => '105'
Previous article: Next article: