Lodash教程

Lodash clone method

语法

_.clone(value)
Creates a shallow clone of value.

参数

value (*) − The value to clone.

输出

(*) − Returns the cloned value.

实例

var _ = require('lodash');
var objects = [{ 'a': 1 }, { 'b': 2 }];
var shallowCopy = _.clone(objects);
console.log(shallowCopy[0] === objects[0]);
Save the above program in tester.js. Run the following command to execute this program.

Command

\>node tester.js

输出

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