This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function multiply(a, b) { | |
return a*b; | |
} | |
function square(a) { | |
setTimeout(function(){console.log('sono asincrono')}, 0); | |
return multiply(a,a); | |
} | |
console.log(square(3)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function multiply(a, b) { | |
return a*b; | |
} | |
function square(a) { | |
return multiply(a,a); | |
} | |
console.log(square(3)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function multiply(a, b) { | |
return a*b; | |
} | |
function square(a) { | |
return multiply(a,a); | |
} | |
console.log(square(3)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sommaNumeriPrimi(numero) { | |
// calcola la somma di tutti i numeri primi da 3 a a numero | |
// stampa nella console il valore ottenuto | |
} | |
const t1 = new Thread(); // pseudo esempio di creazione di un nuovo thread | |
const t2 = new Thread(); // idem | |
t1.sommaNumeriPrimi(2500); // assegna alla variabile "calcolo1" il risultato ottenuto eseguendo sommaNumeriPrimi(2500) sul primo thread | |
t2.sommaNumeriPrimi(1000); // assegna alla variabile "calcolo2" il risultato ottenuto eseguendo sommaNumeriPrimi(1000) sul secondo thread |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log("primo"); | |
console.log("secondo"); | |
// output: | |
> primo | |
> secondo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log(localStorage.studies) /*{"_topics":{"2f346469-d79f-2246-9c72-e0a731c9c830":{ | |
"_name":"C", | |
"completedCounter":0, | |
"skippedCounter":0, | |
"goals":{ | |
"61b07248-5776-0ab0-40dd-78c15a6d1ad6":{ | |
"_description":"ciao", | |
"completed":false}, | |
"48e428f4-22e4-b9c1-fd6d-c553caf9a5e2": | |
{"_description":"ciao2", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
runCountdown() { | |
if (!this._active) { | |
throw new Error('CAN\'T START TIMER IF ACTIVE IS FALSE'); | |
return; | |
} | |
if (this.countdown === 0) { | |
this.disallowTimer(); | |
return; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const stats = new Stats(/*constructor options*/); | |
console.log(stats); | |
/*Stats { | |
firstAccess: '2018-7-5', | |
lastAccess: '2018-8-5', | |
studies: | |
Studies { | |
_topics: | |
{ '9145b69e-d404-91ed-594d-e9d8c7ae5588': [Object], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
addTask(name) { | |
const task = new Task(name); | |
const length = Object.keys(this.tasks).length; | |
this.tasks[length] = task; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Subject { | |
constructor() { | |
// | |
this.observer = undefined; | |
this.attachObserver = this.attachObserver.bind(this); | |
} | |
// | |
attachObserver(observer) { |