If you log a Javascript object to console in a function that gets invoked a larger number of times, and inspect the logs later, all of them would reflect the state of the object at the point in time when you later expand them. This can be a problem when the object is deep orContinue reading “Cloning JS Objects for Logging using JSON”
Monthly Archives: July 2014
Passing Functions to setTimeout in a for Loop
If you pass an anonymous function as the first argument to setTimeout, and the anonymous function makes use of the for loop’s index, each invocation of the callback uses the same value of the index and you may have undesired behavior To avoid this problem, you need to ensure that each callback gets its ownContinue reading “Passing Functions to setTimeout in a for Loop”
Value of ‘this’
Value of ‘this’ ‘this’ can get quite tricky, especially in event callbacks and setTimeout() or setInterval() handlers. For instance, if you extract a method from an object Also, when code is executed later through setTimeout() , ‘this’ refers to the global ‘window’ object. In both these cases, if you want ‘this’ to refer to theContinue reading “Value of ‘this’”
Factory Pattern Example
Factory pattern is one of most used design pattern in Java. This type of design pattern comes under creational pattern as this pattern provides one of the best ways to create an object. In Factory pattern, we create object without exposing the creation logic to the client and refer to newly created object using aContinue reading “Factory Pattern Example”
Heroku supports deploying Java web applications via cmd line
You can upload a WAR file to Heroku and have your web. application up and running on your custom domain. Read this! Its super easy – https://devcenter.heroku.com/articles/war-deployment Essentially, you do the following (these are my internal notes ) 1. Run Maven with package goal to generate a war 3. Login to heroku login 4. GoContinue reading “Heroku supports deploying Java web applications via cmd line”