4.17.11
3.10.1
2.4.2
1.3.1
_.runInContext([context=root])
Create a new pristine lodash
function using the context
object.
Since
1.1.0
Arguments
argument
[context=root]
type
Object
description
The context object.
Returns
(array)
Example
_.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;
_.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;