Javascript Basic Datatypes

  • Basic Datatypes
    • number
    • string
    • boolean
    • undefined
    • null

1. number

  • For numbers (e.g., int, long, float, double), there is only one datatype, number, in Javascript.

2. string

  • Immutable
  • Sequencing

  • string conversion
    • When you use a number-like string as an operand in an arithmetic operation, the string is converted to a number behind the scenes.
    • This works for all operations except addition

3. boolean

  • The boolean variable represents two values: “true” or “false”.
  • If the boolean variable has no initial value, or if the assigned value is one of the followings, it is set to false.
    • 0
    • -0
    • null
    • “”
    • false
    • undefined
    • NaN
  • For any other value, it is set to true (even with the string “false”)!

4. undefined

  • type of undefined is undefined.

5. null

  • type of null is not null, but object.
  • null will be evaluated to 0 (zero), if it is evaluated with other number.

댓글 남기기

이메일은 공개되지 않습니다. 필수 입력창은 * 로 표시되어 있습니다

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    Markdown is turned off in code blocks:
     [This is not a link](

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d 블로거가 이것을 좋아합니다: