我想使用LoDash從數組中刪除一個對象。如何使用lodash從數組中刪除對象?
在server.js
var lodash = require('lodash')();
var rooms = [
{ channel: 'room-a', name: 'test' },
{ channel: 'room-b', name: 'test' }
]
我我去兩個命令嘗試,無法正常工作(的NodeJS):
var result = lodash.find(rooms, {channel: 'room-a', name:'test'});
var result = lodash.pull(rooms, lodash.find(rooms, {channel: 'room-a', name:'test'}));
中的console.log(結果):
LodashWrapper {
__wrapped__: undefined,
__actions__: [ { func: [Function], args: [Object], thisArg: [Object] } ],
__chain__: false,
__index__: 0,
__values__: undefined }
有人可以幫我嗎?謝謝!
我想避免疲勞:P –