◎변수 선언
var name = 'bathingape'
console.log(name)
var name = 'javascript'
console.log(name)
------------------------------------------
let name = 'bathingape'
console.log(name)
let name = 'javascript'
console.log(name)
name = 'react'
console.log(name)
------------------------------------------
const name = 'bathingape'
console.log(name)
const name = 'javascript'
console.log(name)
name = 'react'
console.log(name)
◎리스트 & 딕셔너리
let b_list = [1,2,'hey',3]
b_list[1]
b_list[2]
b_list.push('헤이')
b_list
b_list.length
---------------------------------------------
let a_dict = {}
let b_dict = {'name':'Bob','age':21}
b_dict['name']
b_dict['age']
b_dict['height'] = 180
b_dict
◎함수
function sum(num1, num2) {
console.log('num1: ', num1, ', num2: ', num2);
return num1 + num2;
}
------------------------
let a = function(){
console.log("리터럴 방식 이라고 합니다");
}
a()
◎조건문
function is_adult(age, sex){
if (age > 65 || age < 10) {
alert('탑승하실 수 없습니다')
} else if(age > 20 && sex == '여'){
alert('성인 여성')
} else if (age > 20 && sex == '남') {
alert('성인 남성')
} else {
alert('청소년이에요')
}
}
◎반복문
let people = ['철수','영희','민수','형준','기남','동희']
for (let i = 0 ; i < people.length ; i++) {
console.log(people[i])
}