Javascript - Casting to integer on arithmetic division...
Been rushing on my working project and coding a lot Ajax using Ajax.net lately. Had a lot of re-practice back to javascript. here is a quick pick of one of them.
As Javascript been a weak-typed language, sometimes it's not able to cast a variable from one type to another. as in arithmetic division, if one wants to output an integer instead of a double or else, here is a way learned from this article that's useful:
a = ( b / c ) | 0
by using a bitwise OR operation to cast a float / double back to an integer, to have a way casting some numeric values back to desired form.
also there is a nice Javascript language reference I dig a lot during this coding. thanks for the help!
Technorati Tags: asp.net , programming , javascript