Skip to content

Instantly share code, notes, and snippets.

@neila-a
Created September 17, 2023 03:19
Show Gist options
  • Save neila-a/2644ca744d3255ac695809e6518c495d to your computer and use it in GitHub Desktop.
Save neila-a/2644ca744d3255ac695809e6518c495d to your computer and use it in GitHub Desktop.
Forwarding v1

Forwarding

Any var in this document (either before or after compilation) can be replaced by let if useLet: true is specified.

Constant declaration

const [type] [name] = [value];

will be compiled to:

const [name]: [type] = [value];

Variable declaration

[type] [name] = [value];

will be compiled to:

var [name]: [type] = [value];

Named function declaration

[type] [name]([param with type]) {
     doSomething();
}

will be compiled to:

function [name]([param with type]): [type] {
     doSomething();
}

Arrow function declaration

[type] [name]([param with type]) => doSomething();

will be compiled to:

const [name]: ([param with type]) => [type] = ([param without type]) => doSomething();

Variable named function declaration 1

var [type] [name]([param with type]) {
     doSomething();
}

will be compiled to:

var [name] = function([param with type]): [type] {
     doSomething();
}

Variable arrow function declaration 1

var [type] [name]([param with type]) => doSomething();

will be compiled to:

var [name]: ([param with type]) => [type] = ([param without type]) => doSomething();

Variable named function declaration 2

var function [name]([param with type]) {
     doSomething();
}

will be compiled to:

var [name] = function([param with type]) {
     doSomething();
}

Variable arrow function declaration 2

var arrow [name]([param with type]) => doSomething();

will be compiled to:

var [name] = ([param without type]) => doSomething();

Variable class declaration

var class [name]...

will be compiled to:

var [name] = class [name]...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment