db.mongo.insert({name:'mongo'}); > var t=db.mongo.findOne(); > t{ "_id" : ObjectId("5141b98723616e67f947f356"), "name" : "mongo" } > var d=t > d { "_id" : ObjectId("5141b98723616e67f947f356"), "name" : "mongo" } > d.password=123123> d { "_id" : ObjectId("5141b98723616e67f947f356"), "name" : "mongo", "password" : 123} > t{ "_id" : ObjectId("5141b98723616e67f947f356"), "name" : "mongo", "password" : 123}
问题1
var d = t
是引用赋值吗 如果是的话,怎么样不使用引用赋值
delete d.passwordtrue> d { "_id" : ObjectId("5141b98723616e67f947f356"), "name" : "mongo" } > d.password=124124> d { "_id" : ObjectId("5141b98723616e67f947f356"), "name" : "mongo", "password" : 124, "password" : 124}
问题2 我执行
delete d.password
返回 true 说明已经删除,为什么我再执行
d.password=124
会执行两次添加
> d { "_id" : ObjectId("5141b98723616e67f947f356"), "name" : "mongo", "password" : 124, "password" : 124 }
莫回无
料青山看我应如是
相关分类