Use Array in Javascript tutorial 2

Array in Javascript tutorial 2

array is collection of, numbers, words, or strings or integers or mix of all of these.
How to create array in javascript?

var myArrayName = [1,'khan',343,"54",343]

How to access elements of array?

myArrayName[0];
It will display first element if you print it in console.
Note: Array’s first element is always 0 and then so on

How to find length of array?

myArrayName.length();

How to add elements to array?

myArrayName.push(10)
– Example of integer

myArrayName.push("khan")
– Example of string

How to remove elements from array?

myArrayName.pop() 
– Example of element removal

Tony BB
 

TonyBB is a Coach , marketer, hypnotist and a founder of RSKVF Production who specializes in providing simple, affordable, and easy to use solutions for Life.

Click Here to Leave a Comment Below 0 comments

Leave a Reply: