Javascript: Check if a variable is an Array

This article shows how you can check if a Javascript variable is of an Array type. There are different ways to check if a variable is an Array in Javascript. 1) First way // define an array var myArray = [11, 'John']; console.log(Object.prototype.toString.call(myArray)); // [object Array] // check if the variable is an array if … Read more

Javascript: Multi-dimensional Array & Loop

This is a beginner tutorial on working with Javascript multi-dimensional arrays and looping through them. Javascript Array is a list-like object. It is used to store multiple values in a single variable. This article deals with creating a multi-dimensional Javascript array and using different functions on the array. We also see how we can loop … Read more

Javascript: Array & Loop

This is a beginner tutorial on working with Javascript arrays and looping through them. Javascript Array is a list-like object. It is used to store multiple values in a single variable. This article deals with creating a Javascript array and using different functions on the array. We also see how we can loop through the … Read more

Javascript: Populate Select box OnChange with JS array/object

This article show how to populate one select box by selecting option of another select box/list. We will use a Javascript object. Each key of the object contains array as value. A first select box is populated with the Javascript object’s keys. Then when the value from the first select box is selected then based … Read more

PHP: Parse Unparse String Array

Here is a quick tip on parsing and unparsing string and array in PHP. You can parses the string into variables by using the parse_str PHP function. Using parse_str function void parse_str ( string $str [, array &$arr ] ) $str = The input string. $arr = If the second parameter arr is present, variables … Read more

jQuery: Print array and object

This article shows how to print array and object on jQuery. You can do it with jQuery.each() function. jQuery.each() function can be used to iterate over any collection, whether it is a map (JavaScript object) or an array. Here is the javascript code to print array or object: jQuery(document).ready(function(){ var arr = [ "earth", "mars", … Read more

print_r in Javascript

It’s a real headache when you have to work on objects and arrays in Javascript. It would be lot easier to detect elements of the Javascript objects/arrays if we have print_r function in Javascript like we have in PHP. I googled the web and have found a very efficient print_r Javascript function. Here is the … Read more

PHP Javascript : Playing with multi-dimensional array

I had to work on multi-dimensional array with javascript and php. I had a multi-dimensional array in php. I had to load it into javascript array and then populate the html selection list. The challenge for me was to create multi-dimensional array in javascript and populate selection list with for loop in javascript. Here is … Read more