Joy Online Manual

Differences between Joy and ECMA JavaScript

Joy is mostly a superset of the language defined in the ECMA standard.  There are, however, a few conflicts, such as new keywords which would previously have been accepted as identifiers in ECMA JavaScript. All the incompatibilities are summarized in this chapter.

If you want to run pure ECMA programs, you can switch any Joy JavaScript interpreter into ECMA mode and back again using the version function.



Joy keywords that are legal identifiers in the ECMA standard

Class
NS_DURING
NS_ENDHANDLER
NS_HANDLER
NS_VALUERETURN
NS_VOIDRETURN
SEL
__asm
__asm__
__attribute__
__const
__const__
__declspec
__declspec__
__inline
__inline__
__signed
__signed__
__stdcall
__stdcall__
__volatile
__volatile__
asm
auto
enum
extern
id
inline
register
signed
sizeof
struct
typedef
union
unsigned


Joy keywords that are "reserved" by the ECMA standard

char
const
double
float
int
long
short
static
super
volatile


Joy keywords that are defined differently from the ECMA standard

void

The JavaScript void operator is not present in Joy; you have to use  (void) instead.


Restricted productions

Joy changes the following ECMA production:

MemberExpression:
MemberExpresssion [Expression]

to:

MemberExpression:
MemberExpresssion [no LineTerminator here] [Expression]

This change was necessary to make automatic semicolon insertion work between adjacent Objective-C message expressions.


Char literals

Joy interprets singly-quoted strings of length 1 or 4 as char literals, while ECMA JavaScript would interpret them as strings.


0, false, null

From Joy 2.1 on, 0 == false == null. In ECMA JavaScript, 0 == false, but both 0 != null and false != null.

Index