Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions diary.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const DATA = new Date(2019, 6, 20);
const WEATHER = "sunny";
const LOCATION = "shenzhen";

class Dirkwei {
constructor(name) {
if (!Dirkwei.instance) {
this.name = name;
this.todoList = [];
Dirkwei.instance = this;
}
return Dirkwei.instance;
}

cookAfterWork(food) {
console.log(`${this.name} make ${food}`);
return this;
}

addTempThingsTodo(...fncs) {
this.todoList.push(...fncs);
}

finishTodoList() {
this.todoList.forEach(task => task());
}
}

Dirkwei.instance = undefined;

const me = new Dirkwei("dirkwei");
me.addTempThingsTodo(
() => console.log("read PHP code"),
() => console.log("finish my homework.")
);
me.cookAfterWork("fried dumplings").finishTodoList();