Learn JavaScript
  • Introduction
  • Basics
    • Comments
    • Variables
    • Types
    • Equality
  • Numbers
    • Creation
    • Basic Operators
    • Advanced Operators
  • Strings
    • Creation
    • Concatenation
    • Length
  • Conditional Logic
    • If
    • Else
    • Comparators
    • Concatenate
  • Arrays
    • Indices
    • Length
  • Loops
    • For
    • While
    • Do...While
  • Functions
    • Declare
    • Higher order
  • Objects
    • Creation
    • Properties
    • Mutable
    • Reference
    • Prototype
    • Delete
    • Enumeration
    • Global footprint
Powered by GitBook
On this page
  1. Numbers

Creation

Creating a number is easy, it can be done just like for any other variable type using the var keyword.

Numbers can be created from a constant value:

// This is a float:
var a = 1.2;

// This is an integer:
var b = 10;

Or from the value of another variable:

var a = 2;
var b = a;
PreviousNumbersNextBasic Operators

Last updated 4 years ago