Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

11. Number() > Integers and Floating-Point Numbers

Integers and Floating-Point Numbers

Numbers in JavaScript are typically written as either integer values or floating point values. In the code below, I create a primitive integer number and a primitive floating point number. This is the most common usage of number values in JavaScript.

Live Code

<!DOCTYPE html><html lang="en"><body><script>

var integer = 1232134;
console.log(integer); // logs '1232134'

var floatingPoint = 2.132;
console.log(floatingPoint); // logs '2.132'

</script></body></html>

Note

In JavaScript, a numeric value can be a hexadecimal value or octal value, but this is typically not done.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint