Javascript – Data types and numbers

Javascript has primitive types and objects

primitive types:

  • number 1, 5, 66
  • string ‘Hello’ “World”
  • boolean true false
  • null
  • undefined

objects: anything else than primitive types

Remember that Javascript is a weakly typed language and you cannot declare the type of the variable. You can use the typeof operator to the find the type of a variable.

numbers

The numbers can be:

  • integer 10, 6, 536363
  • signed integer -22
  • decimal 2.3 , -300.12
  • scientific notation 1e1, 2e+3
  • octal 017
  • hexadecimal 0xF1
  • NaN not a number

Number operators

Javascript has binary operators (applied to 2 expressions) and unary operators (applied to 1 expression). Expression is a piece of code that produces a value.

So number operators are:

binary: *, / , – , + , % (modulo returns the remainder)

unary: ++, –, – (the opposite number)

, <span>Javascript – Data types and numbers</span>, KandZ
, <span>Javascript – Data types and numbers</span>, KandZ

THE END!!!

100900cookie-checkJavascript – Data types and numbersJavascript – Data types and numbers

Related posts