我在集合列表中有以下记录
db.ilists.find()
{ "_id" : ObjectId("5efb10f25372d01d549954b1"), "name" : "hello user", "__v" : 0 }
{ "_id" : ObjectId("5efb10f25372d01d549954b2"), "name" : "click + to add items to the list", "__v" : 0 }
{ "_id" : ObjectId("5efb10f25372d01d549954b3"), "name" : "<---click the checkbox to deletet item in the list", "__v" : 0 }
{ "_id" : ObjectId("5efb170a32b1290c64950999"), "__v" : 0 }
{ "_id" : ObjectId("5efb17790d9ff700204c43c2"), "__v" : 0 }
Run Code Online (Sandbox Code Playgroud)
我有两个空文档,我正在使用 deleteMany 删除它们,但我得到以下信息
> db.ilists.deleteMany({"_id":"5efb170a32b1290c64950999"},{"_id":"5efb17790d9ff700204c43c2"})
{ "acknowledged" : true, "deletedCount" : 0 } …
Run Code Online (Sandbox Code Playgroud) 我在这里对可变提升概念有点困惑。为什么第一个console.log(flag)
输出undefined
?它不应该捕获已经初始化的 false 值在作用域链中向上移动吗?
var flag = false;
(function(){
console.log(flag);
var flag = true; // JavaScript only hoists declarations, not initialisations
console.log(flag);
if(flag){
let name = "John";
const age = "24";
console.log(name);
console.log(age);
}
//console.log(name); //ReferenceError: name is not defined ( as name is block scoped here )
//console.log(age); //ReferenceError: age is not defined ( as age is block scoped )
})();
Run Code Online (Sandbox Code Playgroud)