/*
챌린지 두번째 날
밤 12시가 넘어서야 시작했다.
지난번에 python챌린지도 이튿날부터 삼일째 탈락했는데...
이번엔 정말 꾸준히 하자!! 안자고 하고있는 나 칭찬해
자고 담날 함 ,,^.ㅠ 한게 어딘겨
*/
let a = 300;
let b = a + 700;
console.log(b,a);
자바스크립트에서도 씨언어처럼 마지막에 ;을!
변수를 initialize 할 때는 a = 300;이 아닌 let a = 300;
const name = "tahani";
const age = 34;
const height = 180.0;
const female = true;
console.log(name, age, height, female); // 출력
변수를 선언할 때는 기본 const로! 진짜 필요할 때만 let
// Arrays
const daysOfWeek = ["Mon","Tue","Wed","Thu","Fri","Sat","Sun"];
console.log(daysOfWeek);
console.log("오늘은",daysOfWeek[1],"입니다");
console.log(daysOfWeek[6])
const theGoodPlace = ["eleanor","michael","tahani","jianyu","janet","chidi"];
console.log(theGoodPlace);
중간중간에 , 주의 !
console.log(console);
const calculator = {
add : function(a,b){
return a+b;
},
sub : function(a,b){
return a-b;
} ,
mul : function(a,b){
return a*b;
},
div : function(a,b){
return a/b;
},
sqr : function(a,b){
return a**b;
}
}
console.log(calculator.add(3,5));
console.log(calculator.sub(10,2));
console.log(calculator.mul(2,4));
console.log(calculator.div(400,50));
console.log(calculator.sqr(2,3));
function calculator{
...
} 이 아님!
=> console.log에서 console.log(console)하면 위와같이 objects들이 나오는데 이에 접근하려면 .을 이용, console.log로!
const calculator = {
add : function(a,b){
return a+b;
}, sub : function(a,b){ ...}, ...}
'공부 > VanillaJS' 카테고리의 다른 글
[바닐라JS 2주 완성반]3.0-3.1 (0) | 2020.08.12 |
---|---|
[바닐라JS 2주 완성반_Day4]2.5-2.7 (0) | 2020.08.07 |
[바닐라JS 2주 완성반_Day3]2.0-2.4 (0) | 2020.08.06 |
[바닐라 JS 2주 완성반_Day1]1.1-1.5 (0) | 2020.08.03 |