I'm learning design patterns, in one of the tasks in the book i have 2 variables that are global. data and collected. I want to initialize them on start similar to code below. data is input field and collected is function. Task is to do it with singleton, is that even possible?. All examples on the net are just functions and single instance?
"use strict";
var data;
var collected = [];
window.onload = function() {
data = document.querySelector("#data");
colected = function() {
console.log(data);
}
}
Aucun commentaire:
Enregistrer un commentaire