parseInt and Radix
parseInt turns 10.937 into 10, 0.2 into 0, and "someValue" into
NaN. If you use
parseInt without a radix, however, you'll receive a warning that no radix has been provided. In most cases, the radix you want to use is 10:
parseInt(10.83, 10); // 10, no warning
parseInt(.83, 10); // 0, no warning
parseInt(0.8); // 8, unintended result
parseInt(0.8, 10); // 0, intended result
Using a 10 radix means the number is parsed with a base 10 and thus turns the number into the integer you're expecting, without the annoying warning. The radix is important if you're need to guarantee accuracy with variable input (basic number, binary, etc.). For best results, always use a radix of 10!
CSS animations are a lot of fun; the beauty of them is that through many simple properties, you can create anything from an elegant fade in to a WTF-Pixar-would-be-proud effect. One CSS effect somewhere in between is the CSS flip effect, whereby there's...
It's no secret that Facebook has become a major traffic driver for all types of websites. Nowadays even large corporations steer consumers toward their Facebook pages instead of the corporate websites directly. And of course there are Facebook "Like" and "Recommend" widgets on every website. One...
Spatial navigation is the ability to navigate to focusable elements based on their position in a given space. Spatial navigation is a must when your site or app must respond to arrow keys, a perfect example being a television with directional pad remote. Firefox OS TV apps are simply...
Working with textarea widths can be painful if you want the textarea to span 100% width. Why painful? Because if the textarea's containing element has padding, your
"width:100%" textarea will likely stretch outside of the parent container -- a frustrating prospect to say the least. Luckily...