Hey, I'm going to rewrite the main file for my JavaScript library, and I'm looking for better ways to do everything. One of them is that I make the brackets optional, for example, some function calls look like this.
Spark('p').content('Hello, World');
And others like it.
Spark.browser();
So, I have optional parentheses for the Spark function. Am I saying this is the best way?
window.Spark = function(arg1, arg2) {
return {
fn: function() {
alert('run');
}
};
};
for(var f in Spark())
Spark[f] = Spark()[f];
Spark.fn();
Spark(true, false).fn();
It seems to me that this is wrong, although this is the only method that I came up with for this.
source
share