Last updated 5 years ago
Was this helpful?
语法:
_.runInContext([context=root])
源代码链接:
npm包链接:
描述:
创建一个给定context上下文对象的原始的lodash函数。
context
lodash
开始版本:1.1.0
参数:
[context=root] (Object): 上下文对象。
[context=root] (Object)
返回值:
(Function): 返回新的 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;