Notice
Recent Posts
Recent Comments
Link
«   2024/07   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
Tags
more
Archives
Today
Total
관리 메뉴

개발공부일지

Javascript - 연산자, 조건문(if/switch),반복문(while),git 본문

Javascript

Javascript - 연산자, 조건문(if/switch),반복문(while),git

보람- 2023. 6. 29. 17:24

목차

1. 연산자

2. 조건문

3. 반복문

4.git


1. 연산자

 

console.log(1 < 3); //  1이 3보다 작으니까. true
console.log(1 > 3); // 1이 3보다 크다 거짓
console.log(4 >= 2); //4가 2보다 크거나 작다 true
console.log(4 <= 2); // 거짓
console.log(1 == 1); // 같다는 의미는 == 로 표시

console.log("1" == 1); //true 둘이 같은 값을 가진다고 판단해서 1이라서
console.log("1" == true);
console.log(0 == false);
//true 1 false 0 으로 인식
console.log(1 === true); //false 타입이달라서(타입이 같은지까지 확인함)

console.log(1 != "1"); // 거짓!느낌표는 부정의 표현(다른지를)
console.log(1 !== "1"); //true 3개가되면 단순비교가 아니라 타입까지 비교하게됨!!!!!!!
console.log(!true); //true를 반대로해서 false가 나옴

console.log(true && false); // 교집합에 속하는지, 둘다 true인지 확인 -> false
console.log(true && !false); // true

console.log(true || false); // or 을 뜻함, 둘중에 하나라도 트루인지 -> true

console.log(true && "안녕하세요"); //안녕하세요 
// &&는 앞에 false가 오는이상 뒤에껄 볼필요도 없이 false가 나와 - > || or일때는 가능
console.log(false && "안녕하세요"); //false나와
console.log(false || "안녕하세요"); //안녕하세요 나옴 or에서는
console.log(!"안녕하세요"); //false  '안녕하세요'가 true라는것
console.log(!!" "); // true string 문자열이 있을떄 참이나 거짓이냐는 비어있으면 거짓 무언가 하나라도 있으면 참
console.log(!!-1); //참 0의외의 숫자는 다 true
console.log(!!{}); // 데이터가 있다고 인식해서 true
console.log(!![]);
console.log(!!null); //false 비어있다고 판단 0
console.log(!!undefined); //false 비어있어 0
console.log(!!"0"); //문자열로 따져서 true
console.log(0x10); //0x 라고 입력하면 16진수 x=hex ---16
console.log(0o10); //o=octal oct 0o 8진수 ---8
console.log(0b10); //b=bin, binery 0b 2진수 ---2 ,,,보통은 string으로 입력해
console.log("\u00a0"); //unicode
console.log(++a); //6 ++ 하나(1) 증가가 앞에입력하면-- 위에있다고 인식하기
console.log(a); //6
console.log(a++); //6 하나증가를 뒤에입력하면 -- 뒤에있다 라고 인식하기
console.log(a); //7
console.log(--a); // 6 -- 하나 감소
// a -= 1;
// console.log(a);

console.log(a--);
// console.log(a);
// a -=1;

 

2. 조건문

 

① if문

if (a < 0) {
  console.log("a는 0보다 작다");
} else {
  console.log("a는 0보다 작지않아");
}

if (a > 0) {
  console.log("a는 0보다 크다");
} else {
  console.log("a는 0보다 크지않아");
}

if (a < 0) {
  console.log("a는 0보다 작다");
} else if (a < 10) {
  console.log("a는 10보다 작아");
} else if (a < 100) {
  console.log("a는 100보다 작아");
} else {
  console.log("a는 0보다 작지않아");
}

a = 15;
if (a < 0) {
  a *= -1;
} else if (a < 10) {
  a += 10;
} else if (a < 100) {
  a /= 10;
} else {
}
console.log(a);

 

② switch문

a = 1;
switch (a) {
  case 1:
    // case옆에는 값을 입력해서 비교하는
    console.log("a는 1이야");
    break;
  //중괄호 밖으로 나가라는 뜻, 없으면 거짓이여도 그냥 실행되어져
  case 2:
    console.log("a는 2야");
    break;
  default:
    console.log("a는 1도 2도 아니야");
}
console.log("switch 밖이야");

 

3. 반복문

while (a < 100) {
  console.log(a++);
}
while (a < 100) {
  console.log(a);
  a += 1;
}

 

 

4. git

 

- 원격스토리지 (git hub)

- 스냅샷처럼 사진을 찍어 저장하고 어떤게 변했는지 보여준다

  • git init
  • git add .
  • git commit -m "start"
  • git branch -m master
  • git remote add origin 
  • git push -u origin master
  • git pull origin master

 

 오늘의 포인트와 남겨두기 ★

 

console.log(Symbol("a") == Symbol("a")); //false
    → Symbol은 다른것과 같을수가 없다!  (다르다고 인식해서)

※ 계속 입력해보고 공부하기!!!!

 

※ 구구단 만들어보기

※ 0~10 짝수, 홀수 나오게 해보기

 

*** 앞으로 백엔드, 서버를 배우고 블록체인까지 배워 개발자가 되는 그날까지 화이팅!!!!!!!!!!

** 목표에 대해 생각하자!!!!!