Javascript calculation…..
Guys, good day!
After a long time, started blogging again! today wanna discuss 1 important JS issue which we need in our daily development lot of times. When we need to calculate some values like a height of a div and add some extra px to that height, in such a situation we may add a digit with a variable. Sometimes its returns not expected value, its recommended to use ‘ParseInt‘ function to manipulate its correctly.
See below example :
var old_height = $('.mydiv').height(); var new_height = parseInt(old_height+10);
Now new_height has calculated value. we forget the use of this JS function and try to find out the errors, but this simple function needs to be remember in all case of addition.
Its just like a remember for experienced guys and a better practice info for beginner!
Cheers and have good practice!