Lodash教程

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

\>node tester.js

输出

true
false
false
true
昵称: 邮箱:
Copyright © 2022 立地货 All Rights Reserved.
备案号:京ICP备14037608号-4