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

Get notified with the latest posts

Plugin Supporter WordPress Post Navigation
%d bloggers like this: