Skip navigation

var k = Array();

Expecting array…. but k is an object!!!

var k = new Array();
Confused…. now it is also an object and length is 0(zero).  cool…

var k = {}; = ‘kanakarajv’;
what is length of k? hahaha…. it is undefined.
OK. what is k[‘name’]. hehehe… that is great kanakarajv itself. ;-D

var k = {};
k[‘hid  a#2@&^%’]=’kanakarajv’;  // yes. you are right. there is two spaces in between & special characters also.
alert(k[‘hid  a#2@&^%’]);
sorry guys… javascript alerts kanakarajv

var x = Array();
var y = new Array();
var z = {};

What is the difference between these three and why?

After getting all these shock, I decided to break this mystry.

There is an excellent article about Arrays found at javascript-associative-arrays-considered-harmful.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: