Numbers
Get hands-on experience on how to use numbers as a JavaScript data type.
Context: JavaScript data types
When it comes to programming, pretty much everything we do revolves around storing and manipulating data. This data always has a type associated with it that tells the computer exactly how to handle the data that it’s given. In JavaScript, the data’s type is automatically determined when the code is executed.
What exactly do we mean by this? Let’s take a look at an example.
var number1 = 10;var number2 = 20;console.log(number1 + number2);
Pause and think: What do you expect this code to do?
For your reference,
console.log()
outputs to the console whatever data is passed to it in between the parenthesis. You can run the code below to see the output.
var number1 = 10;var number2 = 20;console.log(number1 + number2);
Numbers
Numbers are a numeric data type. Numbers can be integers, floating-point (numbers with a decimal), or exponential values like those you would find with scientific notation.
All numbers in JavaScript are stored using 64 bits of memory. While delving ...