我在javascript变量中有此数据:
var a = {
"answers":[
{"correct":null, "response":true, "text":"x" },
{"correct":null, "response":true, "text":"y" }
]
}
我想将此发送到服务器,但不包括correct
和text
字段。如何删除这些?
试试这个
var result = a.answers.map(function(obj){return {response:obj.response}})
这result
将是一个只有response
字段的对象数组。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句