In JS, what is called this function?

I am trying to find out about this javascript function that I see in the code, but I do not know the name of the construct for google for ...

var Stats = { onLoad: function(e) { // content this.variable++; }, variable: 1 }; 

Is this a way to organize functions and variables based on JSON?

+4
source share
4 answers

This is "Object Literal" - see the JavaScript Guide .

+8
source

He called the syntax Object Literal . This is a superset of JSON.

+4
source

The sample code creates an object literal (i.e. a hash map) with two entries. The first entry maps "onLoad" to an anonymous function, and the second entry maps the "variable" to 1.

+1
source

Thanks guys, I gave Richie an answer for being the first, but the Greg link gave more examples, so I will use both to find out of course (and others from Google).

@Barry: thanks for explaining what he is doing, but actually it wasn’t what I was aiming for by asking a question :)

+1
source

All Articles