1
2
3
4
5
6
7
8
9
10
11
12
13var _ = require('lodash');
const USER = ['id', 'firstname', 'lastname', 'fullname'];
let USER2 = USER;
_.pull(USER2, 'fullname')
console.log(USER);
console.log(USER2);
const TEACHER = ['id', 'firstname', 'lastname', 'fullname'];
let TEACHER2 = _.cloneDeep(TEACHER);
_.pull(TEACHER2, 'fullname')
console.log(TEACHER);
console.log(TEACHER2);1
2
3
4
5
6=== output ===
[ 'id', 'firstname', 'lastname' ]
[ 'id', 'firstname', 'lastname' ]
[ 'id', 'firstname', 'lastname', 'fullname' ]
[ 'id', 'firstname', 'lastname' ]