JavaScript

양희연·2020년 4월 24일
0

JavaScript

목록 보기
1/1
post-thumbnail

💾 데이터 타입

  • number
  • string
  • boolean
  • null 의도적 부재
  • undefined
  • object



𝓧 변수

규 칙
변수명의 첫문자는 숫자이면 안된다.
대소문자를 구별한다.
키워드를 변수명으로 지정할 수 없다.

선 언
let 값을 지정하지 않아도 되며, 재할당이 가능하다.
const 재할당이 불가능하다.

> template literal

const myPet = '멍멍';
console.log(`I have a pet ${myPet}.`);



🚪 조건문

if (true) {
    console.log('참');
} else {
    console.log('거짓');
}

//삼항조건연산자
true ? console.log('참') : console.log('거짓');



🎡 반복문

> for

for (let counter = 0; counter < 4; counter++) {
    console.log(counter);
}

> while

조건이 거짓일 때까지 반복한다.

let counter = 0;

while (counter < 4) {
    console.log(counter);
    counter++;
}



🔩 함수

function greeting(name) {
    console.log(`Hello!! ${name}.`);
}

greeting('bmo')

name parameter
bmo argument

> 함수표현식과 화살표함수

//함수표현식
const calculateArea = function(width, height) {
    return width * height;
};

//화살표함수
const calculateArea = (width, height) => width * height;

💡 매개변수가 하나면 괄호 생략 가능하다.

profile
꾸준히 나아가자!

0개의 댓글