zoukankan      html  css  js  c++  java
  • JavaScript 数据类型转换表

    下表显示了将不同的JavaScript值转换为Number,String和Boolean的结果:

    原始值转换为Number转换为String转换为Boolean
    false 0 "false" false
    true 1 "true" true
    0 0 "0" false
    1 1 "1" true
    "0" 0 "0" true
    "1" 1 "1" true
    NaN NaN "NaN" false
    Infinity Infinity "Infinity" true
    -Infinity -Infinity "-Infinity" true
    "" 0 "" false
    "20" 20 "20" true
    "twenty" NaN "twenty" true
    [ ] 0 "" true
    [20] 20 "20" true
    [10,20] NaN "10,20" true
    ["twenty"] NaN "twenty" true
    ["ten","twenty"] NaN "ten,twenty" true
    function(){} NaN "function(){}" true
    { } NaN "[object Object]" true
    null 0 "null" false
    undefined NaN "undefined" false
    注意:引号("")中的值表示字符串值。在红色的值是程序员可能不希望被转换为的值。
    更多的JavaScript类型转换相关文章。
  • 相关阅读:
    7.ps相关选项
    6.ps的大U和小u区别
    5.进程优先级
    4.状态间的六种转换情况
    3.进程的不同状态
    2.进程与程序的关系
    1.进程概念
    不换行
    for引用变量
    脚本进阶
  • 原文地址:https://www.cnblogs.com/jc2182/p/11582448.html
Copyright © 2011-2022 走看看