This repository has been archived on 2024-06-20. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
coffee.pygments/tests/examplefiles/js/general.js
Mestery fe572dcec9
Update javascript lexer (#1814)
* make ts extends js lexer

* add regex's d flag for js lexers

cf. https://v8.dev/features/regexp-match-indices

* update js builtins, operators, exceptions

* fixup! update js builtins, operators, exceptions

* add typescript override keywork

* Update _mapping.py
2021-07-18 10:36:31 +02:00

72 lines
1.2 KiB
JavaScript

// Most examples from https://github.com/rse/es6-features under MIT license
const PI = 3.141593;
let callbacks = [];
odds = evens.map(v => v + 1);
nums.forEach(v => {
if (v % 5 === 0)
fives.push(v);
})
function f (x, y, ...a) {
return (x + y) * a.length;
}
var params = [ "hello", true, 7 ];
var other = [ 1, 2, ...params ]; // [ 1, 2, "hello", true, 7 ]
f(1, 2, ...params) === 9;
var str = "foo";
var chars = [ ...str ]; // [ "f", "o", "o" ]
var customer = { name: "Foo" };
var card = { amount: 7, product: "Bar", unitprice: 42 };
message = `Hello ${customer.name},
want to buy ${card.amount} ${card.product} for
a total of ${card.amount * card.unitprice} bucks?`;
0b111110111 === 503;
0o767 === 503;
for (let codepoint of "𠮷") console.log(codepoint);
function* ();
*function();
yield;
export class Node {
}
class A {
constructor() {
super()
}
constructor(test) {
super(test);
}
}
isFinite();
isNaN();
x = new Promise(...a);
x = new Proxy(...a);
x ??= 1;
x &&= 2 ?? 3;
x **= 2**3|2&4;
x ||= 2;
throw new Error();
throw new TypeError();
new Uint8ClampedArray();
new DataView();
new Map();
new WeakMap();
Intl.DateTimeFormat();
globalThis = window = global = this;