Reserved words - CoffeeScript in Action (2014)

CoffeeScript in Action (2014)

Appendix A. Reserved words

The CoffeeScript compiler maintains a list of reserved words that will break compilation if you use them as variable names in a program.

For CoffeeScript 1.6.3 the reserved words list appears in table A.1.

Table A.1. CoffeeScript compiler 1.6.3 reserved words

case

default

function

var

void

with

const

let

enum

export

import

native

__hasProp

__extends

__slice

__bind

__indexOf

implements

interface

package

private

protected

public

static

yield

true

false

null

this

new

delete

typeof

in

arguments

eval

instanceof

return

throw

break

continue

debugger

if

else

switch

for

while

do

try

catch

finally

class

extends

super

undefined

then

unless

until

loop

of

by

when

and

or

is

isnt

not

yes

no

on

off

Some of the reserved words in CoffeeScript are reserved because the compiler uses them in the generated JavaScript. Others are reserved because they’re reserved words in the ECMAScript specification, as shown in tables A.2 and A.3.

Table A.2. Reserved words in the fifth edition of the ECMAScript specification

break

do

instanceof

typeof

case

else

try

return

void

continue

for

switch

while

this

with

default

if

throw

delete

in

new

var

catch

finally

debugger

function

There are some words that are reserved for future editions of the ECMAScript specification, as shown in table A.3. Some of them, such as class, also have meaning in CoffeeScript. Don’t use them as identifiers.

Table A.3. Words reserved for future editions of the ECMAScript specification

class

enum

extends

super

export

import

implements

let

interface

package

protected

static

private

public

const

yield

There are some built-in constructors that you should treat as reserved. If you redefine them, you’ll most likely break your programs:

Object, Function, Array, String, Boolean, Number, Date, RegExp, Error, EvalError, RangeError, ReferenceError, SyntaxError, TypeError, URIError

There are other global objects and value properties that you’ve encountered:

Math, JSON, Infinity, NaN

Finally, there are some global functions:

eval, parseInt, parseFloat, isNaN, isFinite, decodeURI, decodeURIComponent, encodeURI, encodeURIComponent