Identifier & keywords

Identifiers (sometimes called symbols) are the names of classes, functions, types, members and fields. In common situations, you can only use letters or characters from any language, plus underscore and dollor sign.

Explicitly define an identifier

You can get a literal identifier with a pair grave accent mark. In this way, you can use any possible characters for its name.

var obj = {
  `name-#42🍎`: 'aleph' // it's legal for a field name.
}

print(obj.`name-#42🍎`) // 'aleph'

Keywords

You cannot use reserved keywords as identifiers.

The full list of current keywords are:

null, true, false, void1, type1, import1, export1, from1, any1, unknown12, never12, var, final, const, def2, delete2, type1, typeval, typeof, decltypeof, namespace, class, enum, fun, struct, this, super, abstract, override2, external, static, extends1, implements12, with12, new, construct, factory, get, set, async2, await2, break, continue, return, for, in, of1, if, else, while, do, when, is, as

1: These keywords are contextual. they only used in specific places, hence can be used as normal identifiers.

2: These keywords have no really effect for now, they are reserved for future development.

Last Updated:
Contributors: 邵燃, chengfubeiming