Skip to main content

Posts

Showing posts from June, 2021

Rapid fire 28 javascript questions and answers .

  Check these rapid javascript questions and answers that will help you to understand Javascript in a different way. Question 1: What is typeof [] ? Ans: Object. Actually, Array is derived from Object. If you want to check the array use Array.isArray(arr) Question 2: What is typeof arguments? Ans: Object. arguments are array-like but not array. it has length, can access by index but can't push pop, etc. Question 3: What is 2+true? Ans: 3. The plus operator between a number and a boolean or two boolean will convert boolean to number. Hence, true converts to 1 and you get a result of 2+1 Question 4: What is '6'+9 ? Ans: 69. If one of the operands of the plus (+) operator is a string it will convert other numbers or boolean to string and perform concatenation. For the same reason, "2"+true will return "2true" Question 5: What is the value of 4+3+2+"1" ? Ans: 91 . The addition starts from the left, 4+3 results 7 and 7+2 is 9. So far, the plus o

Mongodb Basics Set 1: Insert Operation

  In this series, I would be sharing a few basic MongoDB articles on different operations. 1 )Insert a single record in MongoDB collection . var param = { firstname: "joey" , middlename: "" , lastname: "tribani" , phone: 9898989898 } db . collection( 'exampleset' ) . insertOne(param) This returns something like this: { "acknowledged" : true, "insertedId" : ObjectId( "56fc40f9d735c28df206d078" ) } You can also use 'insert' commond for inserting single record . db . collection( 'exampleset' ) . insert(param); This returns : WriteResult({ "nInserted" : 1 }); 2 )Insert multiple records in MongoDB collection . var records = [{ firstname: "joey" , middlename: "" , lastname: "tribani" , phone: 9898989898 },{firstname: "koey" , middlename: "" , lastname: "desuoiza" , phone: 9898989898