There are many instances where we have to execute a function where we have no idea whether it actually exists or not. Let’s say for example, a function expects another function passed to it as parameter, which would later be executed as callback. A very common usage would be the callback function sent to AJAX requests.
Generally, we would code it with an if-block and check whether the variable (say,
callback) is a function or not. If it is, we execute it when we have the work completed (say marked by a variable called
Often, there are conditions where we need to provide a default value of a variable if it is
undefined. As a case study, we will take up the situation, where we are passing a Boolean value to function and if the input is
true, some action has to be taken. In case someone does not pass any value, the input is assumed to be
It has happened with me a number of times that documents got stuck in my print queue like super-glue!
Perhaps it was the wrong document or maybe the wrong printer chosen. In any case, going to printer options and cancelling/deleting the print would result in all but the last document being stuck at “deleting…” state in the printer queue. Nothing would remove that last document from the list of print jobs. And you know that until that small little document is not cleared off the list no other work can be done without getting distracted! Continue reading