how can push data in associative array ?

Forums JavaScripthow can push data in associative array ?
Staff asked 3 years ago

Answers (1)

Add Answer
Staff answered 3 years ago

first create an array of objects

var arr = {'name': []};

next, push the value to the object.

var val = 2;
arr['name'].push(val);

after write in console :

console.log(arr.name[0]);

Subscribe

Select Categories