Q:

Why do arrays behave this way when I add named properties?

I did following experiment in browsers console

I created a new Array.
Added "foo" to the Array as named index "name".
Added "bar" to the Array using push method.

4 & 5 are tests on the  Array
1. var myArray = [];            // undefined
2. myArray["name"] = "foo";     // "foo"
3. myArray.push("bar");         // 1

4. myArray.join(", ");          // "bar"
5. myArray["name"];             // "foo"

My questions (what I didn't understand)

.push() returns 1 which is the length of the Array, but it must be 2 as the Array has two values "foo" & "bar"
Test 4 shows that the Array has only one value "bar" but test 5 oppose it showing that it also has a value "foo".
Why doesn't  Array methods (push, join etc) works on key/value pairs ?
Then how does associative Array works and how we can handle it(methods, properties etc).

A:

.push() returns 1 which is the length of the Array, but it must be 2 as the Array has
  two values "foo" & "bar"

No, because arrays in JavaScript are not associative data structures (even though you can attach arbitrary properties to them). The only items that count as "array contents" are those whose property names satisfy certain conditions.
You should also be aware that length may also report a number greater than what you expect if the array has "holes". For example:
var a = [1, 2, 3];
console.log(a.join(" "), a.length); // "1 2 3", 3
delete a[1];
console.log(a.join(" "), a.length); // "1  3", still 3!

Test 4 shows that the Array has only one value "bar" but test 5 oppose it showing that it also has a value "bar".

That's irrelevant. The array also has many other properties, but join will only touch those mentioned earlier.

Why doesn't Array methods (push, join etc) works on key/value pairs ?

Because that's what the spec says.

Then how does associative Array works and how we can handle it(methods, properties etc).

Use a plain object instead of an array if you want string keys.

A:

JavaScript doesn't really have associative arrays. Being able to do myArray["foo"] = "bar" is a side effect of arrays simply being objects, and objects having properties.
Only numeric properties count as elements of the array. If you do myArray["foo"] = "bar" you are not adding an element to the array, you're simply adding a property to the object. That's different to doing myArray[0] = "bar" which is adding an element, and will accordingly update the length property of the array object.

