멋쟁이 사자처럼 프론트엔드 스쿨 플러스 1기 1주차

안승지·2023년 10월 28일
0

Type

js = weakly typed language

자바와 C++과 같은 강형 언어(strongly typed language)와 달리 JS는 변수 선언시 타입을 지정하지 않는다.
할당한 값에 따라 변수의 타입이 결정되며, 이후 같은 변수에 다른 타입의 값을 재할당하는 것 또한 자유로움.

JS의 약점이자 강점.

값의 전달 등에 있어, 예상치 못한 결과가 나올 수 있음, 그럼에도 런타임 이전에 문제 발견이 불가.

JS는 compile 언어가 아닌 interpretor 언어, 컴파일 단계를 거치지 않기 때문에 코드 실행 이후에 에러 및 문제 발견 가능

=> next_week - 타입 스크립트의 의의
(컴파일 단계에서의 오류 확인 가능)

Primitive & Refrence

원시 타입과 참조 타입 그리고 객체(Object)

Primitive

  • number
  • string
  • boolean
  • null (typeof null = object(?))
  • undefined(=/=null)
  • bigInt, symbol...

Refrence (원시값을 제외한 모든 것들)

  • array
  • *function
  • date
  • regExp(정규표현식)

Object

Object

객체 생성

Object 생성자 함수로 생성

  • dot 연산자(.) 혹은 [속성명] 으로 접근 가능.

JSON 표기법 사용.

var foo = {
  name: 'lee',
  age: 35,
  job: 'teacher',
  married: true
};

for in 구문

객체의 모든 속성 접근에 사용

for(var prop in foo){
  console.log(prop + ": " + foo[prop]);
}

삭제

delete 연산자 사용

delete obj.name

Array

Array 생성자 함수 혹은 JSON 표기법으로 생성 가능

var score = new Array;
var score = [];

for of 구문 & forEach 구문

for(var elem of arr){
  console.log(elem);
}

arr.forEach(function(elem, i){
  console.log(i, elem);
});

Function

명령어 묶음, 특정 기능의 재사용을 위해 사용.

참조타입의 특징

  • 기본 데이터 타입은 실제 데이터를 저장하고 사용 (값에 의한 호출 _ call by value)

  • 참조형 데이터 타입은 실제 데이터가 있는 (메모리)주소를 저장하고 다룸 (참조에 의한 호출
    _ call by reference)

reduce()

const arr = [1, 2, 3, 4];
const initialValue = 0;
const sum = arr.reduce(function(accumulator, currentValue){
  return accumulator + currentValue
}, initialValue);
console.log(sum); // 0 + 1 + 2 + 3 + 4

literal & tagged template literal

구조 분해 할당 (Destructuring assignment)
배열의 구조 분해와 객체의 구조 분해

나머지 매개변수 (Rest parameters) & 전개 연산자 (Spread operator)

Function

일급 객체(First-class object)

함수는 객체다.

열었던 링크들
https://devsoyoung.github.io/posts/js-htmlcollection-nodelist
https://ko.javascript.info/async-await
https://developer.mozilla.org/ko/docs/Web/API/Window/history
https://joshua1988.github.io/ts/guide/generics.html#%EC%A0%9C%EB%84%A4%EB%A6%AD-generics-%EC%9D%98-%EC%82%AC%EC%A0%84%EC%A0%81-%EC%A0%95%EC%9D%98
https://algoroot.tistory.com/55

0개의 댓글