Date

“Util” Methods

_.runInContext([context=root])

source npm package

Create a new pristine lodash function using the context object.

引入版本

1.1.0

参数
[context=root] (Object) : The context object.

返回值
(Function) : Returns a new lodash function.

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