Skip to content

JavaScript Language Support

maximecb edited this page Oct 23, 2014 · 20 revisions

JavaScript Support

JavaScript features supported by Higgs include:

  • Objects and methods
  • Dynamic addition and deletion of object properties
  • Prototype-based inheritance
  • Property attributes (writable/enumerable/configurable)
  • Getter and setter methods (accessors)
  • Garbage-collection
  • Dynamically resizeable arrays
  • Closures
  • Constructor functions
  • Variadic functions and the arguments object
  • If/switch statements
  • For/while/do loops
  • For-in loop
  • Exceptions and try/catch/finally
  • Dynamic code loading with the load() function
  • Evaluation of code strings in the global scope with eval()
  • JSON.parse and JSON.stringify
  • Regular expressions
  • ES6 Map and Set classes
  • UTF-16 strings and string operations
  • Integer and floating-point arithmetic
  • Automatic insertion of missing semicolons

Some features currently missing from Higgs are:

  • The with statement, which is not yet implemented
  • Code evaluated with eval() cannot access local variables, only globals

Language Extensions

Higgs also supports some custom extensions to JavaScript:

  • Command-line arguments accessible through a global arguments object
  • Low-level primitives for arithmetic and pointer manipulation
  • A Foreign Function Interface (FFI) library for interfacing with C code
  • A simple module system based on CommonJS Modules v1.0

Planned Additions

Support for some ES6 features is planned. Notably:

  • The let syntax for variable declarations
  • Abridged lambda syntax (arrow functions)
  • Template strings
  • For-of loops

These features will be added progressively as the ES6 standard becomes finalized. Implementation of ES6 features will depend on available time and the complexity of the changes required to implement these. Support for the easier to implement features will come sooner. We welcome help in implementing ES6 features.