I am learning mongoDB by following the tutorial, http://docs.mongodb.org/manual/tutorial/getting-started/
However, the sample code, var c = db.testData.find()
, confuses me. Without var, the execution just prints out the documents, with the var, c becomes the cursor. The other command, j = { name : "mongo" }
, I don't see the difference with or without var. I want to be clear when I should have var and when I can ignore var.
I google the question little bit, for example, Difference between using var and not using var in JavaScript, it talks about scope. I cannot understand how my question relates to scope.