선언 방법
var score = {‘barcelon’ : 10, ‘real’ : 6, ‘at’ : 5};
var score = new object();
score [‘barcel’] = 10;
score [‘real’] = 6;
score [‘at’] = 5;
값 가져오기
score[‘real’]
> 6
score.real
>6
객체 반복문 - (key)
for(key in score) {
console.log(key);
}
> barcel
real
at
객체 반복문 - (value)
for(key in score) {
console.log(score[key]);
}
> 10
6
5
객체 안의 배열, 객체 안의 함수
var score = {
‘list’ : {‘barcel’ : 10, ‘real’ : 6, ‘at’ : 5},
‘show’ : function() {
for(var name in this.list) {
console.log(name, this.list[name]);
}
}
}
score.show();
> barcel 10
real 6
at 5
'프로그래밍 언어 > Script' 카테고리의 다른 글
JAVA script 정규표현식 (0) | 2022.12.12 |
---|---|
JAVA script 모듈 (0) | 2022.12.12 |
JAVA script 배열 (0) | 2022.12.12 |
JAVA script 내장함수 (0) | 2022.12.12 |
JAVA script 함수 선언 (0) | 2022.12.12 |