
프로젝트를 만들기 전에 자바스크립트 프로그래밍 언어를 배워보자.
학습 날짜 : 23.07.15
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<meta http-equiv='X-UA-Compatible' content='IE=edge'>
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
<title>Momentum</title>
<link rel='stylesheet' type='text/css' media='screen' href='style.css'>
</head>
<body>
<script src='app.js'></script>
</body>
</html>
브라우저 콘솔창을 열어두는 것에 익숙해지도록!
학습 날짜 : 23.07.16
"" 안에 입력해야 함Hello! JavaScript학습 날짜 : 23.07.16
console.log(); : 콘솔에 log 또는 print한다.const : 상수(constant) - 바뀌지 않는 값console.log(5+2);
console.log(5*2);
console.log(5/2);
const a=5;
const b=2;
console.log(a+b);
console.log(a*b);
console.log(a/b);
학습 날짜 : 23.07.16
const : 상수(constant) / 생성 후 값이 바뀔 수 없음let : 생성할 때 사용 / 생성 후 값을 바꿀 수 있음(재선언 X)var : 어디서든 변경 가능(재선언 O)const를 기본으로 사용하고, 업데이트를 해야 한다면 let을 사용하자.
( var은 쓰지 말자! )
학습 날짜 : 23.07.17
null : 아무 것도 없음을 의미undefined : 정의되어 있지 않음을 의미 / 변수를 만들었지만 값을 주지 않았을 경우 / 메모리 안에는 존재하는데 값이 들어가 있지 않음학습 날짜 : 23.07.23
배열대괄호[] 를 사용한다.쉼표,로 분리한다.변수[인덱스]변수.push()학습 날짜 : 23.07.23
object : property를 가진 데이터를 저장중괄호{} 를 사용한다.=을 사용하지 않고, :을 사용한다.쉼표,를 붙인다.const player = {
name : "hy",
points : 20,
fat:false,
};
변수명.속성 = 변경할 속성값player.points = "100";변수명.속성 = 속성값player.lastName = "hi";설명이 필요하지 않은 데이터 리스트들은 array
설명이 필요한 정보가 담긴 데이터 리스트들은 object
학습 날짜 : 23.07.23
function : 어떤 코드를 캡슐화하여, 실행을 여러 번 할 수 있게 해준다.function 함수명(){
//실행할 코드
}
함수명()소괄호() 안에 작성한다.학습 날짜 : 23.07.23
소괄호()에 작성한다.function plus(a, b){
console.log(a + b);
}
plus(2,6);
변수명 : function(){ 실행할 코드 }const player2 = {
name : "Ryan",
sayHello : function(otherPersonName){
console.log("hello! " + otherPersonName + ", Nice to meet you~");
}
};
player2.sayHello("hy");
player2.sayHello("mg");
학습 날짜 : 23.07.24
const와 let의 차이는 데이터를 업데이트 할 수 있는가 없는가이다.const : 데이터 업데이트 Xlet : 데이터 업데이트 Odays[2]=wed;days.push(sun)학습 날짜 : 23.07.24
player.name = "hy";함수명();plus(3,4); function plus(a, b){
console.log(a + b);
}
학습 날짜 : 23.07.25
return 사용학습 날짜 : 23.07.25
const plusResult = calculator.plus(3,7);return을 사용한다.한 번 return하면 function은 끝이 난다!
return을 하면 함수는 작동을 멈추고 결과 값을 반환하고 종료된다.
학습 날짜 : 23.08.05
prompt() : 사용자에게 창을 띄우고 값을 받는다.
typeof키워드를 사용하면 데이터 타입을 확인할 수 있다.
parseInt() : String을 Number로 변환한다.함수는 내부에서 외부로 실행된다.
const age = parseInt(prompt("How old are you?"));
prompt() 함수가 실행된 후 parseInt() 함수가 실행된다.
학습 날짜 : 23.08.05
isNaN() : NaN인지를 판별하는 방법, boolean을 반환한다.if(조건문){
//조건문이 참일 때 실행할 코드
}else{
//조건문이 거짓일 때 실행할 코드
}
학습 날짜 : 23.08.05
if(조건문){
// if 조건문이 참일 경우 실행
}else if(조건문){
// if 조건문이 거짓일 경우 and else if 조건문이 참일 경우
}else{
// if 조건문이 거짓일 경우 and else if 조건문이 거짓일 경우
}
&& (and) : || (or) : === 또는 ==이다.학습 날짜 : 23.08.05
= : 값(value)을 할당한다.=====