Fix MongoError on first connect

The default MongoDb port is 27017. An error occurs sometimes while I am running my Node & ExpressJS application, with the message: message: ‘failed to connect to server [localhost:27017] on first connect [MongoError: connect ECONNREFUSED 127.0.0.1:27017]’ } Several solutions are provided on the internet to fix this. But a lot of them did not work … Read More

Template literals

I have to print a message with values of, say, two variables interpolated or inserted in it. I am talking about JavaScript here. What I do is start single or double quotes, write some part of my message string, close the quotes, insert the variable, start quotes for remaining part of the message and keep … Read More

Some methods of arrays

Iteration of arrays can be done via use of a map function instead of using for loops. Given an array, each element of the array is operated upon. Function creates a new array instead of updating the existing one. // Multiply each element of oldArray with 3 to create a newArray var newArray = oldArray.map(function(val) … Read More

Objects in JS

Objects in JS can be created by: Use of variables Use of functions // table variable | // use of function var table = { | var table = function() { “legs”:4, | this.legs = 4; “color”:”brown”, | this.color = “brown”; “material”:”wood” | this.material = “wood”; }; | }; An instance of these objects can … Read More
Follow

Get notified with the latest posts

Plugin Supporter WordPress Post Navigation
%d bloggers like this: