我有一个可能包含对象或未定义的变量。我希望向此变量添加其他对象。我怎么做?
适用时的代码示例:
function(){
var comments;
if(fbposts[fbpost].comments.count){
for(var comment in fbposts[fbpost].comments.data){
comments = ({
name: fbposts[fbpost].comments.data[comment].from.name,
link: "http://www.facebook.com/"+fbposts[fbpost].comments.data[comment].from.id,
img: "http://www.facebook.com/"+fbposts[fbpost].comments.data[comment].from.id+"/picture",
message: fbposts[fbpost].comments.data[comment].message,
created: timeDifference(Date.parse(fbposts[fbpost].comments.data[comment].created_time)),
})
}
}
return comments;}(),