TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Learn JavaScript Part 15: Arrays
Akshay Patel
Mar 20
2015
Code
904
0
3
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
<!DOCTYPE html>
<html xmlns=
"http://www.w3.org/1999/xhtml"
>
<head>
<title></title>
</head>
<body>
<script id=
"javascript"
>
var
color = [];
color[0] =
"Red"
;
color[1] =
"Blue"
;
color[2] =
"Green"
;
alert(
"You choose :"
+ color[1]);
</script>
</body>
</html>
Output
You choose :Blue
Another Pattern
var
color = [
"Red"
,
"Green"
,
"Blue"
];
alert(
"You choose :"
+ color[1]);
Output
You choose :Green
Another Example
function
addColor()
{
var
temp =
""
;
for
(
var
i = 0; i < arguments.length; i++)
{
temp += arguments[i] +
" "
;
}
return
temp;
}
var
colorList = addColor(
"Red"
,
"Green"
,
"Blue"
);
alert(colorList);
Output
Red Green Blue
JavaScript
JavaScript Arrays
Store multiple values