所以我有一个对象数组,我想在它为空时切片对象的属性.
例如:
var quotes = [
{
quote: "Bolshevism is not a policy; it is a disease. It is not a creed; it is a pestilence.",
source: "Winston Churchill",
citation: "",
year: "29 May 1919",
place: ""
},
{
quote: "Learn while you live",
source: "",
citation: "X",
year: "1950",
place: ""
}];
Run Code Online (Sandbox Code Playgroud)
我有一个对象列表,对象名称随机为空.
我想打印到页面只有非空的属性.
所以我试图遍历对象以找到indexOf()空属性并拼接它:
function findEmptyProp(quotes) {
for (prop in quotes) {
if(quotes[i].children === '') {
return indexOf(quotes[i]);
quotes.splice(i, 1);
}}}
Run Code Online (Sandbox Code Playgroud)
谢谢你的帮助