JavaScript type conversion table

Source: Internet
Author: User

Various types of values

Convert to various types

String

Number

Boolean

Object

Undefined

"Undefined"

NaN

False

Error

Null

"NULL"

0

False

Error

True

"True"

1

Same type

Boolean

False

"False"

0

Same type

Boolean

""

Same type

0

False

String

"2.3"

Same type

2.3

True

String

Oh

Same type

NaN

True

String

0

"0"

Same type

False

Number

-0

"0"

Same type

False

Number

NaN

"NaN"

Same type

False

Number

Infinity

"Infinity"

Same type

True

Number

-infinity

"-infinity"

Same type

True

Number

120

"120"

Same type

True

Number

{A:2,b:3}

"[Object Object]"

NaN

True

Same type

[]

""

0

True

Same type

[5]

"5"

5

True

Same type

[A]

"The"

NaN

True

Same type

[' A ', ' B ', ' C ']

"A,b,c"

NaN

True

Same type

function () {}

"function () {}"

NaN

True

Same type

JavaScript type conversion table

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.