How to create an array in JavaScript?
Submitted by: Administrator► We can create an array in JavaScript as following ways :
► For example :
<script>
var fruits = new Array[];
fruits[0] = "Apple";
fruits[1] = "Orange";
fruits[2] = "Banana";
alert(fruits[1]);
</script>
► It will give output : Orange
► Another easier way to create an array is as follow :
<script>
var fruits = ["Apple","Orange","Banana"];
alert(fruits[0]);
</script>
► This will give output : Apple
Submitted by:
► For example :
<script>
var fruits = new Array[];
fruits[0] = "Apple";
fruits[1] = "Orange";
fruits[2] = "Banana";
alert(fruits[1]);
</script>
► It will give output : Orange
► Another easier way to create an array is as follow :
<script>
var fruits = ["Apple","Orange","Banana"];
alert(fruits[0]);
</script>
► This will give output : Apple
Submitted by:
Read Online Expert Developer JavaScript Job Interview Questions And Answers
Top Expert Developer JavaScript Questions
☺ | Mention what is the disadvantage of using innerHTML in JavaScript? |
☺ | Which keyword is used to print the text in the screen? |
☺ | Why it is not advised to use innerHTML in JavaScript? |
☺ | Explain the concept of unobtrusive JavaScript? |
☺ | How are JavaScript and ECMA Script related? |
Top Scripting language Categories
☺ | AngularJS Interview Questions. |
☺ | Ext-JS Interview Questions. |
☺ | Dojo Interview Questions. |
☺ | Expert Developer JavaScript Interview Questions. |
☺ | jQuery Mobile Interview Questions. |