Archive of JavaScript
Would a setMonth() by Any Other Method Name be as Sweet?
On 31st December 2009 a unit test that had been running successfully in the Caplin continuous integration environment for two months suddenly started failing. The test in question created a JavaScript Date object, modified it using various setter methods, then verified that the format method returned the expected value. The…
Read MoreSupporting IE6 – a poison chalice or the holy grail?
One of the big benefits of Caplin’s browser-based SDP platform, Caplin Trader, is that it can run in virtually any browser without the need for plugins or special configuration. This is no mean feat for a complex, high performance, low latency trading portal framework written in JavaScript and running to…
Read MoreHow to dynamically create a class definition for use with Mock4JS
Mock4JS is a really useful unit testing helper library that allows you to create mocks of your JavaScript classes. What it doesn’t presently support is mocking of objects that you can’t create an instance of yourself using new Class() or of objects that are dynamically created and have functions appended…
Read MoreAdding an Observer to an Observable
The Observer design pattern is used in many applications. If you are unfamiliar with it, or need to remind yourself about the specifics, you can read about it at Wikipedia or MSDN. Caplin Trader even provides a helper class to take care of a lot of the boiler plate code: caplin.core.Observable. The…
Read More