i have code like this:
var db: name = dbFunction(true);
dbFunction returning Object.
I have question, what doing this colon operator in variable name?
i have code like this:
var db: name = dbFunction(true);
dbFunction returning Object.
I have question, what doing this colon operator in variable name?
The colon has several uses in JavaScript.
It's used to separate keys from values in the JSON notation.
var db = { name: dbFunction(name) };
It's the ternary operator:
var db = (1 == 1 ? true : false);
Labels aka
GOTO
. Stay away from them.It's a high tech operator that guarantees a syntax error when used like that.
In it's normal use, you might see it used in object literal syntax to denote key:value pairs;
It can also be used to define a label (less common).
And it's part of the ternary operator;
It is also used in switch cases: