- const set1 = new Set([2,1,3]);
- const set2 = new Set([4,5,6,3]);
- let union = [...[...set1],...[...set2]];
- let t = new Set(union.sort( (a,b) => a-b));
trie un set !
- class Controleur { constructor(view) { this.view = view; this.name = "control" this.bind(); } bind() { console.log(this.name); this.view.bindAdd(()=>this.handlerAdd()); } handlerAdd() { let data = new Date(); this.view.handlerAdd(data); } }
- c = new Controleur(new View());
La view
- class View { constructor() { this.name = "view" this.bAdd = document.querySelector(".add"); this.l = document.querySelector("ol"); } handlerAdd(data) { console.dir(this.name); this.l.insertAdjacentHTML("afterbegin", `<li> ${data}</li>`); } bindAdd(handler) { this.bAdd.addEventListener("click", () => { console.log(this.name); handler(); }) } }
HTML
<body><button class="add" name="buttonAdd" type="submit"> + </button><ol></ol><script src="view.js"></script><script src="controleur.js"></script></body>