MCPcopy Create free account
hub / github.com/circircir-circle/human_exist_device / pluck

Method pluck

mini_program/common/Tools.js:526–534  ·  view source on GitHub ↗

* 返回一个新数组,数组中的元素为指定属性的值 * @param {Array} arr * @param {String} key * @return {Array}

(arr, key)

Source from the content-addressed store, hash-verified

524 * @return {Array}
525 */
526 pluck(arr, key) {
527 if (typeof arr !== 'object' || arr.length === 0) {
528 return []
529 }
530 if (!key) {
531 return arr
532 }
533 return arr.map(a => a[key])
534 }
535
536 /**
537 * 返回序列化的值

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected