2018-03-19 16:33:35 +00:00
|
|
|
import "mod-name";
|
|
|
|
|
import Foo from "bar";
|
|
|
|
|
import * as Food from "food"
|
|
|
|
|
import { Bar, Baz } from "lel";
|
2018-03-20 20:27:06 +00:00
|
|
|
import Bar1, { Foo2 } from "lel";
|
|
|
|
|
import { Bar2 as kex, Baz as food } from "lel";
|
2018-03-19 16:33:35 +00:00
|
|
|
|
|
|
|
|
const x = 0b01;
|
|
|
|
|
let y = 6;
|
|
|
|
|
|
|
|
|
|
export default x;
|
|
|
|
|
export const z = 4;
|
|
|
|
|
export function fun() {}
|
|
|
|
|
export * from "a.js";
|
|
|
|
|
export {A} from "a.js";
|
2018-03-20 20:27:06 +00:00
|
|
|
export {A1, B1} from "a.js";
|
2018-03-19 16:33:35 +00:00
|
|
|
export {C};
|
|
|
|
|
|
|
|
|
|
(a, [b], {c:foo = 3}, ...d) => null;
|
2018-03-21 20:28:40 +00:00
|
|
|
() => {};
|
2018-03-19 16:33:35 +00:00
|
|
|
|
|
|
|
|
async function f() { }
|
2018-03-21 20:28:40 +00:00
|
|
|
function*gen() {
|
|
|
|
|
yield 1;
|
|
|
|
|
yield* 2;
|
|
|
|
|
}
|
2018-03-19 16:33:35 +00:00
|
|
|
|
|
|
|
|
class Class extends Object {
|
|
|
|
|
constructor(...args) {
|
|
|
|
|
}
|
|
|
|
|
foo() {}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
x = class {
|
|
|
|
|
static staticMethod() {}
|
|
|
|
|
static get foo() {}
|
2018-03-20 20:27:06 +00:00
|
|
|
static set bar(value) {}
|
2018-03-19 16:33:35 +00:00
|
|
|
get x() {}
|
|
|
|
|
set x(value) {}
|
2018-03-20 20:27:06 +00:00
|
|
|
static() {
|
|
|
|
|
// "static" can be a method name!
|
|
|
|
|
}
|
|
|
|
|
get() {
|
|
|
|
|
// "get" can be a method name!
|
|
|
|
|
}
|
|
|
|
|
async set() {
|
|
|
|
|
// "set" can be a method name!
|
|
|
|
|
}
|
2018-03-19 16:33:35 +00:00
|
|
|
*bar() {}
|
|
|
|
|
static *baz() {}
|
|
|
|
|
*['constructor']() {}
|
|
|
|
|
static ['constructor']() {}
|
2018-03-20 20:27:06 +00:00
|
|
|
[a]() {}
|
|
|
|
|
"%"(){}
|
2018-03-19 16:33:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
y = {
|
|
|
|
|
get x() {},
|
|
|
|
|
set x(value) {},
|
|
|
|
|
bar() {},
|
|
|
|
|
*bar() {},
|
|
|
|
|
*['constructor']() {}
|
|
|
|
|
}
|
2018-03-20 20:27:06 +00:00
|
|
|
function f () {
|
|
|
|
|
console.log(new.target);
|
|
|
|
|
}
|
2018-03-19 16:33:35 +00:00
|
|
|
console.log([10, ...[], 20, ...[30, 40], 50]["length"]);
|
|
|
|
|
var { w: w1, ...V } = { w: 7, x: 1, y: 2 };
|
|
|
|
|
for (const x of y) {}
|
|
|
|
|
async function f1() { await x + y; }
|
2018-03-20 20:27:06 +00:00
|
|
|
|
2018-03-20 20:48:28 +00:00
|
|
|
``;
|
|
|
|
|
`x`;
|
|
|
|
|
`x${1}`;
|
|
|
|
|
String.raw`\n`;
|
|
|
|
|
|
2018-03-20 20:27:06 +00:00
|
|
|
// arrow.js
|
|
|
|
|
|
|
|
|
|
var foo = ([]) => "foo";
|
|
|
|
|
var bar = ({}) => "bar";
|
|
|
|
|
var with_default = (foo = "default") => foo;
|
|
|
|
|
var object_with_default = ({foo = "default", bar: baz = "default"}) => foo;
|
|
|
|
|
var array_after_spread = (...[foo]) => foo;
|
|
|
|
|
var array_after_spread = (...{foo}) => foo;
|
|
|
|
|
var computed = ({ [compute()]: x }) => {};
|
|
|
|
|
var array_hole = ([, , ...x] = [1, 2]) => {};
|
|
|
|
|
var object_trailing_elision = ({foo,}) => {};
|
|
|
|
|
var spread_empty_array = (...[]) => "foo";
|
|
|
|
|
var spread_empty_object = (...{}) => "foo";
|
|
|
|
|
|
|
|
|
|
// async.js
|
|
|
|
|
|
|
|
|
|
async (x) => await x
|
|
|
|
|
|
|
|
|
|
// destructuring.js
|
|
|
|
|
|
|
|
|
|
var [aa, bb] = cc;
|
|
|
|
|
var [aa, [bb, cc]] = dd;
|
|
|
|
|
var [,[,,,,,],,,zz,] = xx; // Trailing comma
|
|
|
|
|
var [,,zzz,,] = xxx; // Trailing comma after hole
|
|
|
|
|
|
|
|
|
|
var {aa, bb} = {aa:1, bb:2};
|
|
|
|
|
var {aa, bb: {cc, dd}} = {aa:1, bb: {cc:2, dd: 3}};
|
|
|
|
|
|
|
|
|
|
for (const [x,y] in pairs);
|
|
|
|
|
for (const [a] = 0;;);
|
|
|
|
|
for (const {c} of cees);
|
|
|
|
|
|
|
|
|
|
// object.js
|
|
|
|
|
|
|
|
|
|
var a = {
|
|
|
|
|
get,
|
|
|
|
|
set: "foo",
|
|
|
|
|
get bar() {
|
|
|
|
|
return this.get;
|
|
|
|
|
},
|
|
|
|
|
get 5() {
|
|
|
|
|
return "five";
|
|
|
|
|
},
|
|
|
|
|
get 0xf55() {
|
|
|
|
|
return "f five five";
|
|
|
|
|
},
|
|
|
|
|
get "five"() {
|
|
|
|
|
return 5;
|
|
|
|
|
},
|
|
|
|
|
set one(value) {
|
|
|
|
|
this._one = value;
|
|
|
|
|
},
|
|
|
|
|
set 9(value) {
|
|
|
|
|
this._nine = value;
|
|
|
|
|
},
|
|
|
|
|
set 0b1010(value) {
|
|
|
|
|
this._ten = value;
|
|
|
|
|
},
|
|
|
|
|
set "eleven"(value) {
|
|
|
|
|
this._eleven = value;
|
|
|
|
|
},
|
|
|
|
|
*"%"() {
|
|
|
|
|
return 2;
|
|
|
|
|
},
|
|
|
|
|
*["%"]() {
|
|
|
|
|
return 2;
|
|
|
|
|
},
|
|
|
|
|
[a]() {}
|
|
|
|
|
};
|
|
|
|
|
|