javascript - What sort of monster is this? -
I got some javascript that looked like this, and I wonder what was it. It functions like a singleton class defined and installed within a variable declaration. What kind of construction do I say?
& lt; Script & gt; Var abacus = {runningSum: 0, Ads: function (i) {this.runningSum + = i; This return }, Deductible: function (i) {this.runningSum - = i; This return }} Console.log (abacus.addSum (3)); Console.log (abacus.subtractSum (2)); & Lt; / Script & gt;
This is not a monster, it is an unknown object constructor (literal), which is called abacus variable Has been assigned. It has three properties: running, adm, and substratems AddSum and subtractSum anonymous tasks are assigned.
Comments
Post a Comment