본문 바로가기

Coding

[JAVA SCRIPT] a_dict

딕셔너리 = a_dict를 통하여 이름과 변수를 지정해준다.

 

let a_dict = {'name':'song', 'age':29}
undefined

//딕셔너리에 이름 (name)과 변수 (song)을 넣어줬다.


a_dict['name']
'song'

//딕셔너리 상에서 name이라는 값을 불러오도록 입력하였다.

 

a_dict['age']
29

//딕셔너리 상에서 age이라는 값을 불러오도록 입력하였다.

 

a_dict['height'] = 181
181

//딕셔너리에 내가 원하는 값을 넣는 방법이다.

 

a_dict
{name: 'song', age: 29, height: 181}

//a_dict 값 출력시 height:181이 들어가 있는 것을 볼 수 있다

 

a_dict['fruits'] = a_list
(4) ['수박', '참외', '배', '감']
a_dict
{name: 'song', age: 29, height: 181, fruits: Array(4)}

//Array 속에 fruits: (4) ['수박', '참외', '배', '감'] 가 입력되어 있다.

//전에 만들어 놓았던 a_list를 a_dict에 넣을수도 있다.