티스토리 뷰
[] for Array
{} for Object
document.write
- It's a DOM method that allows writing HTML expressions and JavaScript code to a document.
- DOM에서 html처럼 text를 쓸 수 있는 method.
Example code
<script>
var food = {
"fruit" : "orange", //객체의 property는 key 와 value로 이루어져있다
"veggie":"onion",
};
//print the object
document.write("fruit : " + food.fruit + "</br>");
document.write("veggie : " + food.veggie + "</br>");
//add more information
food.snack = "chips";
document.write("snack : " + food.snack + "</br>");
//blank can be added using [" "]
food["cold drink"] = "orange juice"
document.write("drink : " + food["cold drink"] + "</br>");
</script>
|
*key에 공백(띄어쓰기)을 넣어싶으면 [] 를 사용해서 넣어준다. e.g. ["orange juice"]
Result
fruit : orange
veggie : onion
snack : chips
drink : orange juice
Reference
'JavaScript' 카테고리의 다른 글
Callback function in JavaScript (0) | 2019.08.28 |
---|---|
Arrow function in JavaScript (0) | 2019.08.28 |
Closure in JavaScript (0) | 2019.08.27 |
'This' in JavaScript (0) | 2019.08.27 |
String and Number (0) | 2019.08.05 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- easy javascript algorithm
- 알고리즘
- string class in java
- java
- hackerrank javascript solution
- hackerrank solution
- math.abs
- algorithm
- hackerrank
- code refactoring
- easy algorithm
- math.max
- repeat()
- equals()
- Object type casting
- spring boot application
- Javascript Algorithm
- javascript
- HashMap
- 프로그래머스
- HackerRank Algorithm
- 프로그래머스 알고리즘문제
- compareTo()
- ... in Javascript
- C++
- hackerrank javascript
- Collection Framework
- substring()
- 프로그래머스 알고리즘
- rest parameter
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 |
글 보관함