Skip to content

21. 빌트인 객체 #120

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 14, 2023
Merged

21. 빌트인 객체 #120

merged 2 commits into from
Mar 14, 2023

Conversation

Sun4-me
Copy link
Member

@Sun4-me Sun4-me commented Mar 13, 2023

21. 빌트인 객체

✏️ 기억에 남는 내용

  • 자바스크립트 객체의 분류

    • 표준 필트인 객체 : ECMAScript 사양에 정의된 객체, 전역에 공통 기능 제공, 언제나 사용 가능, 전역 객체의 프로퍼티로서 제공됨, 언제나 참조 가능하다.

    • 호스트 객체 : 자바스크립트 실행 환경에서 추가로 제공하는 객체, 클라이언트 사이드 Web API를 호스트 객체로 제공한다.

    • 사용자 정의 객체 : 사용자가 직접 정의한 객체

  • 표준 빌트인 객체

    • 총 40여개의 표준 빌트인 객체 존재

    • Math, Reflect, JSON을 제외하고 모두 인스턴스를 생성할 수 있는 생성자 함수 객체이다.

    • 생성자 함수 객체인 표준 빌트인 객체는 프로토타입 메서드와 정적 메서드 제공, 생성자 함수 객체가 아닌 표준 빌트인 객체는 정적 메서드만 제공한다.

  • 원시값과 래퍼 객체

    • 원시값을 객체처럼 사용하면, 자바스크립트 엔진이 암묵적으로 연관된 객체를 생성하여 이를 가지고 작업 후 다시 원시값으로 되돌린다.

    • 문자열, 숫자, 불리언 값에 객체처럼 접근하면 생성되는 임시 객체를 래퍼 객체라 한다.

    • 래퍼 객체의 처리가 종료되면 가비지 컬렉션의 대상이 된다.

    • null, undefined는 래퍼 객체를 생성하지 않으므로 객체처럼 사용X

  • 전역 객체

    • 코드가 실행되기 이전 단계에서 어떤 객체보다도 먼저 생성되는 특수한 객체

    • 어떤 객체에도 속하지 않은 최상위 객체

    • 브라우저 환경에서는 window(or self, this, frames), Node.js 환경에서는 global

    • 표준 빌트인 객체, 환경에 따른 호스트 객체, var 키워드로 선언한 전역 변수와 전역 함수를 프로퍼티로 가진다.

    • 특징 : 개발자가 의도적으로 생성 불가, window or global 생략 가능, 모든 표준 빌트인 객체를 프로퍼티로 가짐, 실행환경에 따라 추가적으로 프로퍼티와 메서드를 가짐, var 키워드로 선언한 전역 변수와 선언하지 않은 변수에 값을 할당한 암묵적 전역과 전역 함수는 전역 객체의 프로퍼티가 됨, let과 const 키워드로 선언한 전역 변수는 전역 객체의 프로퍼티가 아님, 모든 코드는 하나의 window 전역 객체를 공유한다.

    • 전역 객체의 프로퍼티와 메서드는 식별자 생략이 가능하므로, 전역 변수와 전역 함수처럼 사용 가능하다.

  • 빌트인 전역 프로퍼티 : 전역 객체의 프로퍼티, 전역에서 사용되는 값 제공 - Infinity(무한대 숫자값), NaN(숫자가 아님), undefined

  • 빌트인 전역 함수

  • 암묵적 전역 : 선언하지 않은 변수를 전역 객체의 프로퍼티로 생성


📝 간단한 퀴즈

  1. 전역에서 호출 가능한 빌트인 함수인 eval은 사용을 금지하는데, 그 이유를 간단히 서술하시오.

🧑🏻‍💻 연관 코드

// 관련 코드를 적어주세요.

@Sun4-me Sun4-me self-assigned this Mar 13, 2023
@Sun4-me Sun4-me linked an issue Mar 13, 2023 that may be closed by this pull request
Copy link
Member

@L2HYUNN L2HYUNN left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@BARAM1NG BARAM1NG left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@LSH-0125 LSH-0125 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Sun4-me Sun4-me merged commit dbaa7dd into main Mar 14, 2023
@Sun4-me Sun4-me deleted the 21/Sun4-me branch March 14, 2023 07:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

21. 빌트인 객체
4 participants