An array is used to store a collection of data. In javascript, data doesn’t need to have same type.
var arr = [ 1,"sam", true, {"name":"kumar"} ];
Declaration
Array can be declared in several ways,
Syntax |
Explanation |
Result |
var myArray = new Array() |
Creates Empty Array |
[ ] |
var myArray = new Array(3) |
Creates Array with
Length 3
Value all empty |
[” “,” “,” “] |
var myArray = [3] |
Creates Array with
length 1
Value 3 |
[3] |
var myArray = new Array(1,2,3) |
Creates Array with
length 3
Value 1,2,3 |
[1,2,3] |
var myArray = [“apples”, “bananas”, “oranges”] |
Creates Array with
length 3
Value “apple”, “banana”, “orange” |
[“apple”, “banana”, “orange”] |
Like this:
Like Loading...
Related
Published by
shiyam
My passion became my profession , I'm a driven, energetic and proactive tech professionally. I consider myself an engagement professional, as I don't simply provide solutions, I create them. I am a continuous learner – always looking for new technologies, in my spare time I search Google for the latest trends . I like to think of myself as a futurist and I'm a Full Stack JavaScript Developer.
>> Skills <<
✔ Web App Development
✔ Strong Javascript
✔ Backbone.js, Angular.js, Dojo.js
✔ jQuery.js
✔ Node.js
✔ MongoDb , MySql
✔ Socket.io / Web Sockets (Native)
✔ PHP
✔ Ruby (Watir - Automation)
✔ Grunt
✔ Github , Bitbucket , SVN
✔ Agile Process
✔ Scrum
✔ Ability to research and adapt new techs
✔ Fast Learner
✔ Always Punctual
✔ Critical Thinker
✔ Friendly Personality
View all posts by shiyam