Rounding numbers with decimal places in Javascript

On June 6, 2013, in Javascript, by Anuj Gakhar

By default, Javascript’s Math.round does not support decimal places. If the fractional portion of number is .5 or greater, the argument is rounded to the next higher integer. If the fractional portion of number is less than .5, the argument is rounded to the next lower integer. Here are 2 examples of the above :- […]


Cross Browser Event Handling in JavaScript

On May 22, 2013, in Javascript, by Anuj Gakhar

If you are using jQuery, you can easily use .bind() and .unbind(), or .on() and .off() to attach/detach event handlers on DOM elements. But there are times when jQuery is not available/desirable in the project for various reasons. This is actually quite easy to do in native JavaScript, without any libraries. Most browsers register the […]

Tagged with:  

Using HTML5’s ClassList API

On May 21, 2013, in Browsers, Javascript, by Anuj Gakhar

ClassList is a native and convenient alternative to accessing an element’s list of classes as a space-delimited string via element.className. It makes it easier to accomplish common tasks such as adding class, removing class etc. I find myself using the ClassList API more and more recently (as opposed to the equivalent jQuery functions) and I […]


Writing a Simple Grunt Task using GruntJS

On February 28, 2013, in Javascript, by Anuj Gakhar

In this post, I will be demonstrating how to write a simple Grunt Task that would concatenate and minify your Javascript and CSS source files. GruntJS is a Javascript Task Runner that automates certain tasks and saves a lot of time. There are hundreds of plugins available and the community is growing quite impressively. The […]

Tagged with:  

Setting Railo 4.x service to start on boot on Amazon Linux AMI

On February 25, 2013, in Railo, by Anuj Gakhar

I recently installed Railo 4.0 on a standard Amazon Linux AMI using the Railo 4.0 64-bit installer and everything went fine except that on startup, Railo won’t automatically startup. Even after a re-install (to make sure I had chosen to start Railo at boot during the installation), nothing changed. I still was not able to get […]

Tagged with:  

Mobile Safari CSS :hover selector and Back button

On February 14, 2013, in Browsers, iOS, Javascript, by Anuj Gakhar

Mobile Safari (iOS) has no concept of hover, in general. Obviously, with touch devices, you can’t have this feature. The screen needs to be touched for it to detect any user interaction. That makes sense. And with that in mind, it would be OK to say that we can ignore all :hover CSS rules, because […]

Tagged with:  

Book Review : Twitter BootStrap Web Development How-To

On January 6, 2013, in Books, Web Development, by Anuj Gakhar

I’ve got a review copy of Twitter BootStrap Web Development How-to By Packt Publishing and I’ve just managed to go through the book. The book is authored by David Cochran and because I’ve been using bootStrap in few of my projects, I was quite interested in going through the book, which I believe is the […]

Tagged with:  

AngularJS Directive for Google FastButton

On December 27, 2012, in Javascript, by Anuj Gakhar

In my latest project, I’ve been working on a HTML5 Mobile App for iPad and one of the things we wanted to get rid of was the 300ms click delay that Mobile Safari has. There is a reason for the delay to be there in first place, i.e. the browser is waiting to see whether […]

Tagged with:  

Loading Bootstrap with RequireJS

On November 23, 2012, in Javascript, by Anuj Gakhar

After having heard lots of good things about RequireJS in the past few months, I recently started playing around with RequireJS which is a JavaScript file and module loader, which improves the speed and quality of your code. After reading about it a little bit, the biggest advantage of using RequireJS, that I can see, […]

Tagged with:  

Difference between .call() and .apply()

On November 13, 2012, in Javascript, by Anuj Gakhar

This is a very common Javascript question that confuses a lot of people (including me). You can use both and function.apply() in Javascript to execute a function but what’s the difference? Let’s look at the documentation of call() and apply() first. According to the documentation, .call() means :- Calls a function with a given […]


Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 293 other subscribers

© 2011 Anuj Gakhar