Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set dynamic value to Array in JS like PHP [duplicate]

Tags:

javascript

php

My question is how I will set a value an array in JS like PHP? for example: in php I have an array named Arr, I set a new value in n position using

Arr[] = value

but I try to do same in JS but display an error

like image 471
Jorge Avatar asked Jun 02 '15 21:06

Jorge


1 Answers

Use the push command

Arr.push(value)
like image 128
Jaime Avatar answered Nov 12 '22 15:11

Jaime