//객체(Object)var array = ['사과', '오렌지', '바나나', '귤', '딸기'];var product = {제품명 : '새우깡', 유형 : '과자', 성분 : '새우', 원산지 : '한국'};console.log(array[0] +' '+ array[2]);console.log(typeof(product) +' '+ product['성분']+' '+product['유형']);console.log(product.성분 +' '+product.원산지);// 객체의 키는 식별자 & 문자열을 모두 사용가능하다.// 단, 키로 문자열 사용시에는 대괄호를 사용해서 객체요소에 접근 할 수 있다.var obj = {'number test' : 273, 'special character' : '~!@#$%^&*()_+}'};//객체의 다양한 자료형var object = {number : 273, //숫자형string : 'Bong', //문자형boolean : true, //boolean형array : [52, 273, 103, 32] ,//배열형method : function(){ //함수console.log('함수');}};//객체와 반복문var product = { name : 'Microsoft ..', price : '15000', language : '한국어', supportOs : 'win 32/64', subscription : true};var output = '';for(var p in product){output += p + ' ' + product[p] + '\n';}console.log(output)
'dev > JavaScript' 카테고리의 다른 글
[jsTree] jsTree plugin 알아보기 (0) | 2021.03.04 |
---|---|
[jsTree] jsTree 사용해보기 (0) | 2021.03.03 |
jQuery Code Assist (jQuery 코드 자동완성) (0) | 2017.05.06 |
여러가지 객체사용법 2 (0) | 2017.04.27 |
여러가지 객체사용법 1 (0) | 2017.04.27 |
//객체(Object)var array = ['사과', '오렌지', '바나나', '귤', '딸기'];var product = {제품명 : '새우깡', 유형 : '과자', 성분 : '새우', 원산지 : '한국'};console.log(array[0] +' '+ array[2]);console.log(typeof(product) +' '+ product['성분']+' '+product['유형']);console.log(product.성분 +' '+product.원산지);// 객체의 키는 식별자 & 문자열을 모두 사용가능하다.// 단, 키로 문자열 사용시에는 대괄호를 사용해서 객체요소에 접근 할 수 있다.var obj = {'number test' : 273, 'special character' : '~!@#$%^&*()_+}'};//객체의 다양한 자료형var object = {number : 273, //숫자형string : 'Bong', //문자형boolean : true, //boolean형array : [52, 273, 103, 32] ,//배열형method : function(){ //함수console.log('함수');}};//객체와 반복문var product = { name : 'Microsoft ..', price : '15000', language : '한국어', supportOs : 'win 32/64', subscription : true};var output = '';for(var p in product){output += p + ' ' + product[p] + '\n';}console.log(output)
'dev > JavaScript' 카테고리의 다른 글
[jsTree] jsTree plugin 알아보기 (0) | 2021.03.04 |
---|---|
[jsTree] jsTree 사용해보기 (0) | 2021.03.03 |
jQuery Code Assist (jQuery 코드 자동완성) (0) | 2017.05.06 |
여러가지 객체사용법 2 (0) | 2017.04.27 |
여러가지 객체사용법 1 (0) | 2017.04.27 |