Lodash runInContext method
语法
_.runInContext([context=root])
Create a new pristine lodash function using the context object.
参数
[context=root] (Object) − The context object.
输出
(Function) − Returns a new lodash function.
实例
var _ = require('lodash');
_.mixin({ 'foo': _.constant('foo') });
var lodash = _.runInContext();
lodash.mixin({ 'bar': lodash.constant('bar') });
console.log(_.isFunction(_.foo));
console.log(_.isFunction(_.bar));
console.log(lodash.isFunction(lodash.foo));
console.log(lodash.isFunction(lodash.bar));
Save the above program in
tester.js. Run the following command to execute this program.
Command
输出