HOw do you create an array in Java Script to list names entered by the user?
Answers
Answered by
0
Answer:
Explanation:
Hi,
There are two ways of making array in javascript
1. Using Array() function
or
2. Using array literal []
Let's see how to make an array using Array() function
syntax:
var nameOfArray = Array(value1, value2, value3, ...);
example:
var myFriends = Array('Ajay', 'Pankaj', 'Sandeep', 'Mukesh');
and now let's array literal syntax and example
syntax:
var nameOfArray = [value1, value2, value3, ...];
example:
var myFriends = ['Ajay', 'Pankaj', 'Sandeep', 'Mukesh'];
Attachments:
Similar questions
Math,
6 months ago
Math,
1 year ago
Math,
1 year ago
Social Sciences,
1 year ago
Social Sciences,
1 year ago
Political Science,
1 year ago