property
is not a property here. It's a label-- something you could use with break
or continue
. You could reformat the code you have like this:
function test() {
property:
true;
alert('testing');
}
You're not actually referencing the label, and the thing that comes after it (true) is just a no-op statement, so nothing happens when it executes. The function only meaningfully contains an alert statement.
You seem to be confusing an object literal with a function definition. You could create an object with properties like this:
var test = {
property: true;
};
You might also be confusing it with a couple other patterns. Let us know what you're trying to accomplish for more info.