Lodash教程

Lodash prototype.plant method

语法

_.prototype.plant(value)
Creates a clone of the chain sequence planting value as the wrapped value.

参数

value (*) − The value to plant.

输出

(Object) − Returns the new lodash wrapper instance.

实例

var _ = require('lodash');  
function square(n) {
   return n * n;
}
 
var wrapped = _([1, 2]).map(square);
var other = wrapped.plant([3, 4]);
 
console.log(other.value());
console.log(wrapped.value());
Save the above program in tester.js. Run the following command to execute this program.

Command

\>node tester.js

输出

[ 9, 16 ]
[ 1, 4 ]
昵称: 邮箱:
Copyright © 2022 立地货 All Rights Reserved.
备案号:京ICP备14037608号-4