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

Method 2

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

Method 3

How to check if a javascript function exists or is defined?

To check if a Javascript function exists before calling it, try this:

If you want to reduce the number of strings hanging around in your code, try this instead

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 .

You created an object foo.

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