Sharp Tutorial
array in js

Python

Java

C

C++

HTML/CSS

Java Script

PHP

SQL

C Programs

Java Script

  • java script home
  • introduction
  • Variable Declare & Make Comment
  • operator
  • if else
  • loop
  • Array
  • Function
  • Java Script Objects
  • Java Script DOM

JS based examples

  • two number sum and diff programs
  • Pattern program in java script
  • zumble word quiz
  • Random number guess program
  • calculator in java script
  • digital clock in java script

HTML

  • HTML Home
  • Introduction
  • Commonly used tags
  • Formatting
  • Working with class
  • Apply Css
  • Layout
  • Link / Image
  • Html Forms
  • Html Tables
  • Responsive Design

CSS

  • Introduction
  • Types of Css
  • Background and Color
  • Css Formatting
  • Css Layout
  • Css Animation
  • Css Table
  • Css Effects
  • Css Pagination
  • Css Media Query

Java Script Array

Array is the collection of multiple values  so while using array we can store multiple values in a single variable at continuous locations. Index of the array starts from 0 and goes upto size-1 of the array

In JS array may be declared as following.

 

var city=["Delhi","Mumbai","Chennai","Kolkata"];

Array may also be created as following 

 

var country=new Array("India","Pak","Srilanka","Nepal");

We can access a value of array by using index as following . To store a value at given index we uses as following .In following example at 0 index “new delhi ” stores instead of delhi

 

city[0]="New Delhi";

To print any value at the given index we use as following. 

 

document.write(city[2]);

    Output: Chennai

length:- Length of the array may also be calculated as following

 

document.write(city.length);

    Output: 4

Array program to print all values in reverse order

 

<html>
<title>JS introduction</title>
<head>
<script>
var color=["Red","Blue","Black","Green"];
for(i=color.length-1;i>=0; i--)
{
document.write(color[i]);
}
</script>
</head>
<body>
</body>
</html>

    Output: Green Black Blue Red 

[codepen_embed height="265" theme_id="default" slug_hash="QWwKVzJ" default_tab="js,result" user="rajputadesh"]See the Pen QWwKVzJ by rajput adesh (@rajputadesh) on CodePen.[/codepen_embed]

Enquiry about Course

Ask your Question

Click Here

Sharp (2) Tutorials

Video/ C Introduction

Watch video in full size

Video tutorial

Follow by Email
Facebook
Facebook
fb-share-icon
YouTube
Copyright © Sharp Tutorial
Build with WordPress
Wordpress Social Share Plugin powered by Ultimatelysocial
Sharp Tutorial