JavaScript: Source Code Encoding

By Xah Lee. Date: . Last updated: .

What's JavaScript's Charset?

JavaScript source code's charset is Unicode.

It means, JavaScript source code can contain any character of Unicode. For example, including any Chinese character, or Egyptian Hieroglyph, or emoji.

What's JavaScript's default encoding for source code?

JavaScript spec does not specify a default encoding for source code file. It depends on the encoding from HTTP protocol configured by the web server. [see HTTP Protocol Tutorial]

UTF-8 encoding is recommended. You should save JavaScript file in UTF-8 encoding. UTF-8 is the standard encoding for much of web technologies.

[see Unicode Basics: Character Set, Encoding, UTF-8]

[see HTML: Character Sets and Encoding]

Reference

js spec 2016 encoding 2020-05-12 r6vrd
ECMAScriptยฎ 2016 Language Specification#sec-ecmascript-language-source-code
โˆ‘ JS in Depth
XAH ย BUY NOW

JS in Depth

JS Obj Ref

DOM


JS in Depth

Basic Syntax

Value Types

Variable

String

Function

Property

Object and Inheritance

Array

Constructor/Class

Iterable ๐ŸŒŸ

Misc