Testing Parameters in MS Ajax
Garbin has a great post that explains the possibility of creating a strongly typed collection in JavaScript. It’s very easy to read, and ends up with this sample code. This is all accomplished with a Function._validateParams that is built into the core library. It’s a nice short read, that explains the features very nicely.
function pageLoad() {
var c1 = newsamples.Customer();
c1.set_fullName('John Doe');
var c2 = new Samples.Customer();
c2.set_fullName('John Smith');
var coll = new Samples.CustomerCollection();
coll.addCustomer(c1);
coll.addCustomer("blah"); // This will throw.
coll.removeCustomer(c1);
alert(coll.get_count());
}
Published with BlogMailr