Skip to content

literals

Yongku cho edited this page Jan 30, 2023 · 25 revisions

결론

https://twitter.com/BrendanEich/status/1339614885953511424?t=7lujMcxc5d3nENAyYdx2Mg&s=19

var undefined = void 0 사례

이후 undefined에 값을 할당할 수 있으므로 void 0을 사용하라는 답변도 있었음 (링크)

개발자들이 var undefined = void 0; 을 사용 중이라 하위 호환성을 위해 undefined를 global object에 추가했음.

undefined에 대해서

undefined는 global object에 정의되었는데, null은 literal에 정의한 이유가 무엇일까

https://2ality.com/2021/01/undefined-null-revisited.html

  • null은 Java의 null literal 스펙을 가져왔으므로 null이 literal에 정의되었음
  • 고민을 다시 생각해보면 undefined를 global object에 정의한 이유가 필요하다

null은 literal에 정의되었는데, undefined는 global object에 정의한 이유가 무엇일까?

https://www.ecma-international.org/publications-and-standards/standards/ecma-262/

  • ES3부터 Value properties of the Global Object 스펙에 undefined 추가됨

TC39 질문 후 답변

https://es.discourse.group/t/why-undefined-is-not-literals/1489

If you mean that undefined is not a keyword, and null is - I'm not sure why this was originally the case, but changing it now (or likely even back in ES3) would break the web.

https://github.com/tc39/ecma262/issues/2932

This was already asked on discourse: https://es.discourse.group/t/why-undefined-is-not-literals/1489/3 and that's the only proper place to ask.

global object

https://exploringjs.com/deep-js/ch_global-scope.html#conclusion-why-does-javascript-have-both-normal-global-variables-and-the-global-object

스펙 문서

null 스펙

https://tc39.es/ecma262/multipage/ecmascript-language-expressions.html#prod-Literal

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Grammar_and_types#literals

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/null

undefined 스펙

https://tc39.es/ecma262/multipage/global-object.html#sec-undefined

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined

https://developer.mozilla.org/en-US/docs/Glossary/Global_object

Clone this wiki locally