Manage Learn to apply best practices and optimize your operations.

Prevent JavaScript from treating numbers as strings when using '+'

This tip describes a method for preventing JavaScript from treating numbers as strings when using '+'.

Sometimes when using JavaScript for calculations, JS treats numbers as string when I use + (addition). If this happens, you can use - (subtraction) and multiply with -1 (negative 1). This forces JS to treat the number string as a number. Very useful in loops, and when getting the number string from e.g. window.document.all.elemID.innerText

: var a=window.
var total=a(id1).innerText-

Dig Deeper on JavaScript for Lotus Notes Domino



  • Favorite iSeries cheat sheets

    Here you'll find a collection of valuable cheat sheets gathered from across the iSeries/ community. These cheat ...

  • HTML cheat sheet

    This is a really cool cheat sheet if you're looking to learn more about HTML. You'll find just about everything you every wanted ...

  • Carol Woodbury: Security

    Carol Woodbury