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

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

c# - Create dynamic LINQ query expression at runtime which translates into a parameterized SQL query for nullable types -

cmake - cpack generates RPMs with %files entries that conflict with the RPM spec. How to fix? -