Get to know MDN better
This page was translated from English by the community. Learn more and join the MDN Web Docs community.
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2015년 9월.
Symbol() 함수는 타입 Symbol의 원시 값을 반환합니다.
문자열. 디버깅에는 사용할 수 있지만 심볼 자체에 접근하기 위해 사용할 수 없는, 심볼에 대한 설명입니다.
새로운 원시 심볼을 만들기 위해서는 아래와 같이 설명으로 사용할 선택적 문자열과 함께 Symbol()을 사용하면 됩니다.
위의 코드는 세 개의 새로운 심볼을 생성합니다. Symbol("foo")는 문자열 "foo"를 강제로 심볼로 만들지 않습니다. 매번 새로운 심볼을 생성합니다.
new 연산자를 사용한 아래 구문은 TypeError를 발생시킵니다.
이는 작성자가 새 심볼 값 대신 명시적인 Symbol 래퍼 개체를 만드는 것을 방지하며 원시 데이터 타입을 중심으로 명시적인 래퍼 개체를 만드는 것이 일반적으로 가능하기 때문에 놀랄 수 있습니다(예: new Boolean, new String and new Number).
정말로 Symbol 래퍼 객체를 생성하려면 Object() 함수를 사용할 수 있습니다.
| ECMAScript® 2027 Language Specification # sec-symbol-constructor |
Enable JavaScript to view this browser compatibility table.
This page was last modified on 2025년 10월 9일 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.