1
我遇到了一些顯而易見的問題。我似乎無法刪除節點中的對象的屬性。這是咖啡文字,但我認爲這不相關。無法刪除行爲
console.log doc
delete doc.password
console.log doc
返回:
{ firstname: 'Andrew',
lastname: 'Plummer',
email: '[email protected]',
password: 'blahblah',
_id: 5014c0a6af36bdaf03000001,
comments: [],
posts: [] }
{ firstname: 'Andrew',
lastname: 'Plummer',
email: '[email protected]',
password: 'blahblah',
_id: 5014c0a6af36bdaf03000001,
comments: [],
posts: [] }
對於一些看似那麼明顯其實我已經繞計算器搜索和Google搜索了約半小時。對不起,如果我仍然錯過了重複。
你會顯示:'(function(){doc = {firstname:「Andrew」,lastname:「Plummer」,email:「andrew @ stackoverflow ...」,密碼:「blahblah」,_ id: 「5014c0a6af36bdaf03000001」,評論:[],帖子:[]},console.log(「刪除前:」+ doc.password),刪除doc.password,console.log(「刪除後:」+ doc.password)} )()' – 2012-07-29 07:07:35
@Andrew,'password'屬性可能是通過調用[Object.defineProperty()]定義的(https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Object/defineProperty ),其中'可配置'描述符字段被省略(或明確設置爲'false')。在那種情況下,不能「刪除」該設計屬性。 – 2012-07-29 08:06:45