I thought these were equivalent.
var __Panel = {
this.header = null;
};
var __Panel = function() {
this.header = null;
};
The first one gives a compiler error “Expected identifier or string” for this, and “Expected ‘,'” for ;.
Can someone clarify this a little for me?
{}is used to define an object, andfunction(){}is used to define a function.Thos body inside of
{}must be a series of comma-separatedkey: valuepairs, like this:Your example doesn’t work for three reasons. First,
this.headeris not a valid key because it contains a dot,:rather than=is the token used to separate keys from the values, and,is used instead of;to delimit key-value pairs.