Im creates a JavaScript object with literal notation, but Im not sure how to make the parameters for getting the object like this:
hi.say({title: "foo", body: "bar"});
instead of hi.say("foo", "bar"); .
Current code:
var hi = { say: function (title, body) { alert(title + "\n" + body); } };
The reason I want it is because I want people to be able to skip the header and just put the body in and do the same for many other parameters.
That's why I need something like how we can use jQuery function {parameter:"yay", parameter:"nice"}
PS Im also open to modify the current method - bearing in mind that there will be many parameters, some are required and some are optional, and which cannot be ordered in a certain way.
source share