연산
let c = 'aaa'
let d = 'bbb'
console.log(c+d)
console.log('1'+2)
console.log(`문자열 더하기 = ${1+2}`);
console.log(1+2);
console.log(3-2);
console.log(4/2);
console.log(2*3);
let a = 7
let b = 5
console.log(++a);
console.log(--b);
let x = 3;
let y = 6;
console.log(x += y);
console.log(x -= y);
console.log(x /= y);
console.log(x *= y);
let fiveNum = 5
let fiveStr = '5'
console.log(fiveNum == fiveStr)
console.log(fiveNum !== fiveStr)
console.log(fiveNum === fiveStr)
console.log(fiveNum !=== fiveStr)
const name1 = {name:'kim'}
const name2 = {name:'kim'}
const name3 = name1
console.log(name1==name2)
console.log(name1===name2)
console.log(name3===name1)
console.log(null == undefined)
console.log(null === undefined)
조건문과 반복문
let name = 'park'
if(name=='kim'){
console.log('yes')
}else{
console.log('no')
}
console.log(name === 'kim' ? 'yes' : 'no')
let browser = 'ie'
switch(browser){
case 'ie' :
console.log('yes')
break;
case 'chrome':
console.log('no')
break;
case 'firefox':
console.log('what')
break;
default:
console.log('browsers')
break;
}
let i = 3
while (i > 0){
console.log(i)
i--;
}
do{
console.log(`do while: ${i}`)
i--
}while(i>0)
let n = 4
for(let i = 1; i<10; i++){
console.log(n * i)
}
let x = 0;
for(let i = 0; i<=10; i++){
if(i % 2 !== 0){
continue;
}else{
console.log(i)
}
}
for(let i = 0; i<=10; i++){
console.log(i);
if(i == 8){
break;
}
}