0% found this document useful (0 votes)
8 views

3rdk Practical Css

This is third practical

Uploaded by

mayur
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

3rdk Practical Css

This is third practical

Uploaded by

mayur
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Name :Mayur Sankpal Roll no:90

Practical 3rd of CSS

Array functionality
Array simple code
Eg 1]
<html>

<body>

<script>

var i;

var emp=new Array();

emp[0]="mayur";

emp[1]="onkar";

emp[2]="ganesh";

for(i=0;i<emp.length;i++){

document.write("<br>"+emp[i]);

</script>

</body>

</html>

Output:
Eg 2]
<html>
<body>
<script>

var i;
var emp=["onkar","mayur","ganesh","balaji"];
for(i=0;i<emp.length;i++){

document.write("<br>"+emp[i]);
}
</script>

</body>
</html>
Output :

Extra Programs:
1]Perform Array function
<script>
var array=new Array();
array[0]=12;
array[1]=67;
array[2]=22;
array[3]=44;
array[4]=30;
var s=array.sort();
document.write("sorted array :"+s);
var s=array.sort();
var c=s.reverse();
document.write("<br>revers array :"+c);
var i=array.indexOf(22);
document.write("<br>index of 67:"+i);
var l=s.lastIndexOf(22)
document.write("<br>last index of 22:"+l);

//var m=array.find(44);
//document.write("<br>after find :"+m);
array.push(33,54);
document.write("<br>after push :"+array);

array.unshift(65,66);
document.write("<br>after unshift :"+array);

array.pop();
document.write("<br>after pop :"+array);
array.shift();
document.write("<br>after shift :"+array);
</script>

Output:

2]Array push and pop operation


<script>
var a=new Array(1,2,3,4,"mayur");
document.write("array is:"+a);
a.push("onkar",5,6,7,55.55);
document.write("<br>array after push:"+a);
a.pop();
document.write("<br>array after pop:"+a);
var s=a.sort();
document.write("<br>array after sort:"+s);
s.reverse();
document.write("<br>array after reverse is:"+s);

</script>
Output:
2]shift and unshift methods.
<script>
var a=new Array(1,2,3,4,5);
document.write("array is:"+a);
a.shift();
document.write("<br>array after shift:"+a);
a.unshift();
document.write("<br>array after unshift:"+a);

</script>

Output:

You might also like