|
|
|
|
|
1. Objects by hierarchy: window, document, ... |
|
2. Objects unrelated to hierarchy: array, date, function, ... |
|
Property = an object attribute or characteristic |
|
Method = function or role |
|
|
|
|
|
Object notation => |
|
object.property=value document.gbcolor='red' |
|
object.method window.close() |
|
parentObject.childObject.property='value' |
|
document.form1.ID(name).value='Hong Gil-dong' |
|
|
|
|
|
Array |
|
Handling two or more values of the same type together = multiple values can be stored in one variable |
|
|
|
Notation) |
|
Declaring it as an array tells the variable that it is an array. |
|
1. 1) var variable=new Array() |
|
2) var variable=new Array(4) :: I will store up to 4 items. |
|
|
|
variable[0]=value1; |
|
variable[1]=value2; |
|
variable[2]=value3; |
|
variable[3]=value4; |
|
|
|
2. var variable = new Array(value1, value2, value3, value4); |
|
3. var variable = [ "value1","value2","value3","value4" ] |
|
|
|
|
|
yoil (below) becomes the object, |
|
and length (which returns the number of elements) becomes the property. |
|
|
|
|
I talked too much... haha
Let us store the seven days of the week in one variable.
First, there are two-
|
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ko" lang="ko"> |
|
|
|
|
|
<head> |
|
|
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" /> |
|
|
|
|
|
<title> </title> |
|
|
|
|
|
<script type="text/javascript"> |
|
|
//<!CDATA[ |
|
|
|
|
|
var yoil=new Array(); |
|
|
yoil[0] = "Monday" ; |
|
|
yoil[1] = "Tuesday" ; |
|
|
yoil[2] = "Wednesday" ; |
|
|
yoil[3] = "Thursday" ; |
|
|
yoil[4] = "Friday" ; |
|
|
yoil[5] = "Saturday" ; |
|
|
yoil[6] = "Sunday" ; |
|
|
|
|
|
blood=["a","b","ab","o"]; |
|
|
|
|
|
for(i=0; i < yoil.length; i++){ |
|
|
document.write(yoil[i] + "<br />"); |
|
|
} |
|
|
for(i=0; i < blood.length; i++){ |
|
|
document.write(blood[i] + "<br />"); |
|
|
} |
|
|
|
|
|
//]]]]]]> |
|
|
</script> |
|
|
|
|
|
</head> |
|
|
|
|
|
|
|
|
<body> |
|
|
|
|
|
|
|
|
</body> |
|
|
|
|
|
</html> |
|
|
|
