callback

Unlike many other programming languages, JavaScript enables you to freely pass functions around to be executed at a later time. A callback is a function that is passed as an argument to another function and is executed after its parent function has completed. Callbacks are special because they patiently wait to execute until their parent finishes. Meanwhile, the browser can be executing other functions or doing all sorts of other work.
A definition taken from jquery website

Reference: Michael Vollmer

One should also understand about callback hell

Set multiple css style properties in Javascript

In three different methods you can set multiple style properties to an element using javascript.

for example, consider, you want to apply colour, border colour and visiblity to an element with id myElement

Method 1

document.getElementById("myElement").style.color = "#000";

document.getElementById("myElement").style.borderColor = "blue";

document.getElementById("myElement").style.visiblity = "visible";

Method 2

document.getElementById("myElement").style.cssText = "color: #000; border-color: blue; visibility: visible";

Now, the above step is going to replace the existing inline style. If you want to keep existing inline style and add these styles additionally, here is the trick

document.getElementById("myElement").style.cssText +=';'+ "color: #000; border-color: blue; visibility: visible";

Method 3

document.getElementById("demo").setAttribute("style",  "color: #000; border-color: blue; visibility: visible");

JSON cyclic structure

Several times, you might have ended up with the Javascript error “TypeError: JSON.stringify cannot serialize cyclic structures” and you must be wondered what is  JSON cyclic structure?

Here is an example for JSON cyclic structure .

var foo = {};
foo.bar = foo;

You created an object foo.

Then you assigned the same object foo to a property of foo to create JSON cyclic structure.