返回输入数组指定列
- npm i sx-array-column
import sxArrayColumn from "sx-array-column";
const arr = [{id: 1, name: "zhangsan"}, {id: 2, name: "lisi"}, {id: 3, name: "wangwu"}];
console.log(sxArrayColumn(arr, "name")); // 返回 ["zhangsan", "lisi", "wangwu"]
console.log(sxArrayColumn(arr, "name", "id")); // 返回 [ { '1': 'zhangsan' }, { '2': 'lisi' }, { '3': 'wangwu' } ]