From the category archives:

Technical Publications

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 workIsDone.)

Continue reading

{ 0 comments }

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 true.

Continue reading

{ 3 comments }

Infinite Ways to Detect Array in JavaScript

Technical Publications

JavaScript (ECMA script in general) is a miraculous language. It allows us to prove that coding is creativity. One reason for that is the numerous ways a single objective can be coded. For instance, checking whether a variable is an Array, can be done in four different ways. And probably more!

Some months back I had come across this Quora article: What’s the best way to tell the different between an Array and other kinds of objects in JavaScript? There were already five different methods available there from Tom, John, Rick, Ken and Eric. And even I was surprised that I could add one more! I would take some time and explain all the methods with its pros and cons and finally we can conclude upon the best method.…

August 27, 2011 0 comments

Optimized Trapping of Undefined-like Values In JavaScript

FusionCharts

While working on the FusionCharts JavaScript charts, there was a frequent need to test whether a variable was null, undefined, NaN or an empty string. The “frequent” need was so frequent that the probing function alone took up 15% of the chart’s execution time.

December 30, 2010 0 comments

Dynamically Update FusionCharts XML Attributes

FusionCharts
Thumbnail image for Dynamically Update FusionCharts XML Attributes

This snippet of code adds the functionality to dynamically update FusionCharts DataXML root attributes (also known as “chart attributes”) on-the-fly using JavaScript.

In case user requires to update chart cosmetics like turn off animation or change chart caption, this script will allow developers to do that in one line of code!

May 30, 2010 1 comment

Making FusionCharts Occupy 100% Width and Height of Container

FusionCharts

Under certain circumstances, one may want FusionCharts to occupy 100% (or a certain percentage) width and height of the container element. This can be achieved using two methods using the jQuery Plugin for FusionCharts.

March 30, 2010 6 comments

Convert HTML Tables to Animated Charts

FusionCharts

Most of us already have data on our web-pages in form of tables. With the release of the jQuery Plugin for FusionCharts, giving life to tabular data couldn’t have been easier. With just one line of code, one can convert HTML tables into animated FusionCharts.

March 23, 2010 2 comments

jQuery Plugin for FusionCharts 1.0 Beta Released

FusionCharts

Yesterday, jQuery Plugin for FusionCharts Free was released as a beta release candidate. With it’s release, FusionCharts has bridged certain parts of the gap that lay between FusionCharts and popular JavaScript libraries.

March 21, 2010 3 comments

Transpose An Array In JavaScript and jQuery

Technical Publications

This JavaScript code adds the functionality to transpose a two-dimensional JavaScript array (array within array). Transposing, in simple terms, is to interchange rows and columns of a matrix (two-dimensional array).

It also extends jQuery to allow transposing of arrays using common jQuery syntax.

February 24, 2010 1 comment

FusionCharts On WordPress In 11 Easy Steps

FusionCharts

Manually installing FusionCharts in your WordPress blog is extremely easy. One requires nothing more than copy-paste skills to create lovely animated charts in one’s WordPress blog using FusionCharts.

Here are eleven simple and direct steps that would make your WordPress blog (or any other blog) up and running with FusionCharts in minutes.

February 20, 2010 11 comments