Lodash教程

Lodash noConflict method

语法

_.noConflict()
Reverts the _ variable to its previous value and returns a reference to the lodash function.

输出

(Function) − Returns the lodash function.

实例

var _ = require('lodash');
var lodash = _.noConflict();
function vowels(string) {
   return lodash.filter(string, function(v) {
      return /[aeiou]/i.test(v);
   });
}
console.log(vowels('Julie'));
Save the above program in tester.js. Run the following command to execute this program.

Command

\>node tester.js

输出

[ 'u', 'i', 'e' ]
昵称: 邮箱:
Copyright © 2022 立地货 All Rights Reserved.
备案号:京ICP备14037608号-4