Skip to content
lightweight syntax additions to javascript, from a curmudgeon who loves javascript just the way it is
Find file
Failed to load latest commit information.
bin add cli Jan 8, 2012
vendor Add multiline strings. Jan 7, 2012 Add multiline strings. Jan 7, 2012
binary.jsx initial commit Jan 7, 2012
class.jsx Add multiline strings. Jan 7, 2012
cli.jsx add cli Jan 8, 2012
index.js initial commit Jan 7, 2012
package.json add jabba bin directive in package.json Jan 8, 2012
repl.jsx add cli Jan 8, 2012
test.js initial commit Jan 7, 2012
unary.jsx initial commit Jan 7, 2012



Jabbascript is the result of being presented with the question (not but 12 hours ago!) what I would change about JavaScript -- at the language level -- if I could.

Well, it turns out, I really don't want to change that much. I've tried CoffeeScript; it left me with a syntactic sugar headache. Maybe I can't help myself: I just really like JavaScript the way it is!

That said, I recently saw @jashkenas propose a simple class syntax that desugars nicely to ES3/5. I've loosely adapted it here, along with three other changes.


class [NAME] [extends EXPR] EXPR

returns a Function

// the new class syntax:

var X = class {
    init:function(x, y) {
        this.x = x
        this.y = y

// desugars to:

var X = function(x, y) {
    this.init.apply(this, []

X.prototype.init = function(x, y) {
    this.x = x
    this.y = y

// named classes:

class GaryBusey {
    // `init` is the magic constructor.
    yell:function() {
        return "GLADLY"

// and linking prototypes:

// to function constructors...
class MyList extends Array {
    map:function() {
        // superclass methods are available on `superclass`.
        return, [] 

// and objects.
class MyList extends {a:1} {



attempts to return a function bound to the LHS from an attribute on the RHS

This may prove to be a bad idea.

Basically, when a : is encountered in a terminal position in a lookup chain, it automatically binds the function at the name being looked up to the rest of the chain.

An example:

    var contrived = {
        examples : {
            are : {
                the: {
                    best:function() { return this.message }
                    message:"don't you think?"

    var a_note = contrived.examples.are.the:best

    a_note()    // === "don't you think?"

    // this actually desugars to:

    var a_note =

    // #### WARNING, these are buggy right now. You cannot use them in ?: ternaries. ####



returns the function represented by EXPR bound to the current value of this.

When used in a unary position, the colon binds the function to the right to the current value of this.

var x = {
    messageFactory: function() {
        return :function() {
            console.log('message from '
    name:"gary busey"

It binds tighter than most unary operations (due to a gross, hacky solution), so you can write functions like this:

class Parent {
    init:function(name, age) { = name

class Child extends Parent {
    init:function(name, age, toys) { = toys

        // ooo:
        :Child.superclass.init(name, age)

Multiline Strings

Just adds multiline string support:

var myString = """
    hi there
""" + '''

How to use

require'ing jabbascript will add a require hook for .jsx files. These files can contain the formulations above.

If you spot any bugs, lemme know. There's sure to be millions.

An admonition

This is very much so a WIP. It is licensed MIT.

Something went wrong with that request. Please try again.