How to adds new elements to the end of an array, and returns the new length in JavaScript

2 Answers

0 votes
var numbers = [9, 25, 100, 81];
numbers.push(225);
document.write(numbers);


/*

run:

9,25,100,81,225 

*/

 



answered Apr 6, 2017 by avibootz
0 votes
var numbers = [9, 25, 100, 81];
var len = numbers.push(225);

document.write(len + "<br />");
document.write(numbers);


/*

run:

5
9,25,100,81,225 

*/

 



answered Apr 6, 2017 by avibootz
...