In PHP I can do like:
$arrayname[] = 'value';
Then the value will be put in the last numerical key eg. 4 if the 3 keys already exists.
In JavaScript I can’t do the same with:
arrayname[] = 'value';
How do you do it in JavaScript?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can use the
pushmethod.For instance (using Firebug to test quickly) :
First, declare an array that contains a couple of items :
The array contains :
And now,
pusha new value to its end :The array now contains :