[Solved] Array in javascript like php


JavaScript arrays are designed for numeric indexes and hold ordered data.

Use objects to store properties with arbitrary names.

var p = {};
p["abcd"] = "James";

In JS, an array is a kind of object so it is possible to store arbitrary properties on it, but you will run into problems when you attempt to iterate over the array or pass it to functions such as JSON.stringify.

If you are using ES6 than Maps are another option.

3

solved Array in javascript like php