I’m working on a Dashboard widget and I came across a code that looks like this:
var variableName = {
"SomeName":"someValue",
"someName": "another value",
};
That’s pretty much a sum of what it looks like. My question is what is it, how does it work and what can I do with it? An example would be perfect. Thanks in advance!
While it’s called an object literal in JavaScript, it acts more like an enum in most languages.
With that in place, you have an easy to read way of determining message state:
This is also an easy way to organize functional pieces within your JS file. If you want to only use one JS file for you entire site, which is highly recommended for all kinds of optimization, you can use this instead of writing several different functions:
And to call: