JavaScript Basic

소재현·2022년 7월 21일
0

- 데이터 타입

기본형(원시형)

strng 문자열

"문자", '123',"abc","true"

number 숫자

123

boolean

true/false
null 의도적으로 비어둠
undefined 못찾는것

참조형

object 객체

const obj = {key:"value", key:"value", "hello world":"hello"};

array배열

const arr = [1, 2, 3, 4, 5];
console.log(typeof 123213);
console.log(typeof "string");

변수

값을 담을수 있는 그릇
변수 선언 규칙

선언

var
재선언과 재할당이되서 잘 쓰지않는다 휴먼 오류가 있을수있음
let
let name;
console.log(name);
name = "steve";
console.log(name);
재선언은 되지않고 재할당은 된다
const
const number = 123;
console.log(number);

함수

선언문의 소가로는 매개변수 파라미터
const hi = "hello";
const hellow = "123";
function gretting(input, second){
//본문 body
return "hello " + input + second;
}
//호출문의 소가로는 인자이다(함수호출문)
gretting(hi, hellow);

input

function grettingTwice(){
return gretting("hello","123") + "hello world";
}
console.log(grettingTwice());

비교연산자

// <,>,<=,>=,===,==,
1>2;
1 == "1";
1 ==="1";

논리 연산자

//&&(and), ||(or), !(not)

1 && 1;
1 && 0;

boolean을반환

//조건문
if(true){

}else{
//if문의 조건이 false 일 떼 else의 body가 실행
}

0개의 댓글