SET !

  1. const set1 = new Set([2,1,3]);
  2. const set2 = new Set([4,5,6,3]);

  3. let union = [...[...set1],...[...set2]];

  4. let t = new Set(union.sort( (a,b) => a-b));
trie un set ! 


début de MVC

 Le contrôleur

  1. 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); } }
  2. c = new Controleur(new View());

 La view

  1. 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>