Notice
Recent Posts
Recent Comments
Link
초짜코딩의 잡동사니
데이터 불러오기 : 객체 본문
13. 객체 : 데이터 불러오기 : 기본
{
const obj = {
a: 100,
b: 200,
c: "javascript"
}
document.write(obj.a);
document.write(obj.b);
document.write(obj.c);
document.write(obj["a"]);
document.write(obj["b"]);
document.write(obj["c"]);
}
결과보기
100
200
javascript
100
200
javascript
200
javascript
100
200
javascript
14. 객체 : 데이터 불러오기 : Object
{
const obj = {
a: 100,
b: 200,
c: "javascript"
}
document.write(Object.keys(obj));
document.write(Object.values(obj));
document.write(Object.entries(obj));
}
결과보기
a,b,c
100,200,javascript
a,100,b,200,c,javascript
100,200,javascript
a,100,b,200,c,javascript
15. 객체 : 데이터 불러오기 : 변수
{
const obj = {
a: 100,
b: 200,
c: "javascript"
}
const name1 = obj.a;
const name2 = obj.b;
const name3 = obj.c;
document.write(name1);
document.write(name2);
document.write(name3);
}
결과보기
100
200
javascript
200
javascript
16. 객체 : 데이터 불러오기 : for in
{
const obj = {
a: 100,
b: 200,
c: "javascript"
}
for(let key in obj) {
document.write(obj[key]);
}
}
결과보기
100
200
javascript
200
javascript
17. 객체 : 데이터 불러오기 : map()
{
const obj = [
{a: 100, b: 200, c: "javascript"}
]
obj.map(function(el){
document.write(el.a);
document.write(el.b);
document.write(el.c);
});
}
결과보기
100
200
javascript
200
javascript
'JavaScript' 카테고리의 다른 글
데이터 실행하기-1 (0) | 2022.04.13 |
---|---|
데이터 불러오기 : 객체2 (0) | 2022.04.13 |
데이터 불러오기 - 배열2 (0) | 2022.02.17 |
데이터 불러오기 : 배열 (0) | 2022.02.16 |
데이터 불러오기 : 변수/상수 (0) | 2022.02.16 |