: 프로그래밍 언어 중 하나로, 브라우저가 알아들을 수 있는 언어
- <head> ~ </head> 안에 <script> ~ </script> 로 공간을 만들어 작성
let a = 1
let b = 2
a+b // 3
a/b // 0.5
let first = 'Bob'
let last = 'Lee'
first+last // 'BobLee'
first+' '+last // 'Bob Lee'
first+a // Bob1 -> 문자+숫자를 하면, 숫자를 문자로 바꾼 뒤 수행
let a_list=['수박','참외','배']
a_list.push('감')
a_list // ['수박','참외','배','감']을 출력
let b_dict = {'name':'Bob','age':21}
b_dict['height'] = 180
b_dict // {name: "Bob", age: 21, height: 180}을 출력
names = [{'name':'bob','age':20},{'name':'carry','age':38}]
new_name = {'name':'john','age':7}
names.push(new_name)
function is_adult(age){
if(age > 20){
alert('성인이에요')
} else if (age > 10) {
alert('청소년이에요')
} else {
alert('10살 이하!')
}
}
(age > 20 && sex == '여')
(age > 65 || age < 10)
for (let i = 0; i < 100; i++) {
console.log(i);
}
for (1. 시작조건; 2. 반복조건; 3. 더하기) {
4. 매번실행
}
let scores = [
{'name':'철수', 'score':90},
{'name':'영희', 'score':85},
{'name':'민수', 'score':70},
{'name':'형준', 'score':50},
{'name':'기남', 'score':68},
{'name':'동희', 'score':30},
]
for (let i = 0 ; i < scores.length ; i++) {
if (scores[i]['score'] < 70) {
console.log(scores[i]['name']);
} 🚨원하는 특정 데이터가 있을 경우 ['~']으로 지정
}