Take the example:
$.ajax({lhs:val});
What does the {} do? As far as I know, there's no named parameters -- so is this an actual member (same as $.ajax.lhs)? What does it mean and what does it do?
That is object literal notation. It is creating an object with a lhs property, set to val.
It is another way to do the following
var obj = new Object();
obj.lhs = val;
$.ajax(obj);
In jQuery, many functions take an options object, which is just a plain object with various properties set to determine how the function acts.
It's a literal for an object.
var anObject = { member1: "Apple",
member2: function() { alert("Hello"); } };
alert(anObject.member1); // Apple
anObject.member2(); // Hello
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With