git clone https://github.com/ariya/esprima.git
cd esprima
git checkout -b harmony origin/harmony
open demo/parse.html
git remote add constellation https://github.com/Constellation/esprima.git
git fetch constellation
git checkout -b harmony-template-strings constellation/harmony-template-strings
// extends Base
class Derived extends Base {
// constructor
constructor() {
this.type = 'derived';
}
sayHello() {
console.log('derived');
// we can call super of own method
super();
}
sayHello2() {
// we can call other super mathod
super.sayHello();
}
}
sayHello method functionholds own method name and home
function sayHello() {
...
}
sayHello.__MethodName__ = 'sayHello';
sayHello.__Home__ = Derived.prototype;
Derived.prototype.sayHello = sayHello;
method.[[Home]]
objectas environment.[[HomeObject]]
method.[[MethodName]]
objectas environment.[[MethodName]]
environment.[[GetSuperBase]]()
returnsenvironment.[[HomeObject]].[[Prototype]]
class Dog {
bow(n) {
console.log(n + ' bow!');
}
say() {
// `this` is Dog instance
// arrow can take expression as body
[1, 2, 3, 4].forEach(e => this.bow(e));
// this also works fine
() => {
this.bow(100);
};
}
}
// using expression in ${}
let hello = `Hello ${name}!`;
// We can write raw string
let raw = String.raw`This is
raw string including
LineTerminator`;
// And we can use it like this
let html = escapeHTML`<p>${url}</p>`;
// example quasi literal
let name = "Yusuke Suzuki";
re`hello ${name}!\nGood afternoon.`;
// comes to re function
cooked = ['hello ', '!\nGood afternoon.'];
cooked.raw = ['hello ', '!\\nGood afternoon'];
re(cooked, name);
function StringRaw(callSite) {
var raw = callSite.raw;
var len = raw.length;
if (!len) {
return '';
}
var next = 0;
var result = '';
while (true) {
result += raw[next];
++next;
if (next === len) {
return result;
}
result += arguments[next];
}
}
Table of Contents | t |
---|---|
Exposé | ESC |
Full screen slides | e |
Presenter View | p |
Source Files | s |
Slide Numbers | n |
Toggle screen blanking | b |
Show/hide slide context | c |
Notes | 2 |
Help | h |