boseok-note
  • README
  • javascript
    • 함수형 자바스크립트
    • core
      • 이벤트루프 (Event Loop)
      • boxing, unboxing
      • prototype
      • 실행컨텍스트
      • hoisting
      • 클로져(Closure)
      • arguments
      • Scope - 스코프 - 유효범위
    • api
      • Promise
      • Fetch API
      • worker-api
      • Web API
    • lib
      • rxjs
        • rxjs
    • 호스트객체?
    • es6
      • var-let-const
      • template-literals
      • async-await
    • tip
      • array-like
      • Object literal, new Object
    • dom-api
      • HTML Element get Text
      • get-size
      • scrollToBottom
    • for in, for of 차이
    • storage
    • Constructor (생성자)
    • Javascript
    • module
  • front-end
    • vuejs
      • vue-rx
      • README
        • 1-start
        • 2-basic-component
        • 3-add-component
        • 4-advanced-component
        • 5-dynamic-methods-event
        • 6-internal-process
      • next-tick
      • compare-react
      • v-model-with-props
      • v-for
      • vuejs
      • vuex
    • browser
      • dom
      • cssom
      • reflow, repaint
      • 렌더링 트리(Rendering Tree)
      • web-standard
    • css
      • text-ellipse
      • white-space
      • css layout
    • Pre-render
    • react-native
      • react-native
    • 최적화 관련
    • reactjs
      • performance
      • reactjs
    • CSR, SSR
  • server-side
    • letsencrypt
    • auto-deploy
    • nlb
    • Certbot, aws https setting with wildcard
    • mysql
    • node.js
      • npm
        • npm install
      • node-dynamodb
      • node에서 간편하게 letsencrypt를 사용하여 https 구현하는 방법
    • Docker
    • nginx
    • Amazon Web Service
    • nginx https 설정
  • design-pattern
    • observer
    • flux
    • README
  • coop
    • git
      • gitignore
      • remote
      • ssh key 사용하기
      • password
      • credential
      • git
  • cs
    • port
    • data-structure
      • tree
      • binary-tree
    • network
      • home-router
      • tcp-udp
      • http
    • process
  • etc
    • sync-async
    • seo
      • seo
      • SEO Check Point
    • rest
    • unity
      • methods
Powered by GitBook
On this page
  • 객체 생성의 두가지 방법과 차이
  • new 연산자를 사용해서 객체를 만드는 경우
  • 유리한점
  • 불리한점
  1. javascript
  2. tip

Object literal, new Object

객체 생성의 두가지 방법과 차이

객체를 생성할때, new Object, {} 두 가지 방법으로 객체를 생성한다.
두가지 방법에 대해 얼핏 봤을때 차이가 없어보이고, 일반적으로 리터럴 방법으로 객체를 생성한다.
그리고 그 어디에도 이런 차이점에 대해서는 별로 설명하고 있지않다.
(사실 내용이 별로 없고 당연해서 설명할 필요도 없긴하다.)
하여튼 차이점에 대해 아래에 정리해보려고한다.

new 연산자를 사용해서 객체를 만드는 경우

유리한점

프로토타입상속을 활용할때 유용하다.
(리터럴 구문으로 객체를 생성하면 상속체인을 관리하기 힘들다.)
프로토타입 메소드가 많다고 가정하면 이해하기쉽다.

불리한점

실제로 얼마 차이가 나진않지만 코드가 더 길고 귀찮다.
객체를 생성할때 속도가 리터럴 방식보다 느리다.

끄읏.

Previousarray-likeNextdom-api

Last updated 6 years ago