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