while(parentId){
ancestors.push(parentId);
parent = Comments.findOne(parentId);
if(typeof parent.parentCommentId === "undefined"){
break;
} else {
parentId = parent.parentCommentId;
console.log(parentId);
}
}
我想要這段代碼推送數組中的所有parentCommentId,直到top.But頂級評論文檔沒有字段parentCommentId。流星檢查findOne結果是否有屬性
而且我在控制檯此錯誤 Cannot read property 'parentCommentId' of undefined {stack: (...), message: "Cannot read property 'parentCommentId' of undefined"}
typeof運算和hasOwnProperty不行,我怎麼能檢查屬性
使用回調函數來獲取響應。 – BatScream 2014-12-03 19:02:50