-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex8.html
99 lines (76 loc) · 2.51 KB
/
index8.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<!DOCTYPE html>
<html>
<head>
<title>This is My First HTML</title>
<meta charset="UTF-8">
<style>
</style>
</head>
<body>
<button onclick="myfunction(this)" title="button1">Button 1</button>
<button onclick="myfunction(this)" title="button2">Button 2</button>
<button onclick="myfunction(this)" title="button3">Button 3</button>
<button onclick="myfunction(this)" title="button4">Button 4</button>
<script>
/*var ar=[123,3546,76,689];
var ar1=Array(32,45,67,768,789789);*/
var fruits=["Apple","Mango","Kiwi","Banana"];
//var fruits="eyhjf";
//document.write(typeof(fruits));
//returns type of variable
//document.write(Array.isArray(fruits));
//return if var is array or not
//document.write(fruits.toString());
//convert array to string
//document.write(fruits.join('*'));
//join all elements
//fruits.push("Papaya");
//insert one element at last index
//fruits.pop();
//remove one element at last index
//fruits.unshift("Papaya");
//insert one element at first index
//fruits.shift();
//remove one element from first index
//fruits[2]="Papaya";
//replace element of that index
//delete fruits[1];
//delete element from array but index is occupied
//fruits.splice(0,2);
//will remove element from array splice(index, no. elements to delete);
//fruits.splice(1,0,"Papaya");
//will remove element from array splice(index, no. elements to delete, element to add);
//document.write(fruits);
var fruits1=["banana","Mango"];
var fruits2=["papaya","lichi"];
//document.write(fruits1+fruits2);
//document.write(fruits1.concat(fruits2));
//to add arrays
//var fruits3=fruits.slice(1,3);
//document.write(fruits3);
//document.write(fruits.sort());
//sort array elements in alphabatical order
//document.write(fruits.reverse());
//array elements in reverse order
//fruits.sort();
//document.write(fruits.reverse());
var obj={
'name':'Bhavna',
"email":'[email protected]',
'contact':234567,
};
//document.write(obj['name']);
//document.write(obj.name);
obj.address="23,sdssdf";
for(x in obj){
//document.write(x+"<br>");
//document.write(obj[x]+"<br>");
}
function myfunction(a){
//console.log(a);
//alert(a.getAttribute('title'));
a.style.color="red";
}
</script>
</body>
</html>