search

Home  >  Q&A  >  body text

var num1 = 10; 和var num1 = "10"; 有什么区别?

声明下面两个,怎么感觉输出是一样的啊

var num1 = 10;
var num1 = "10";

phpcn_u224phpcn_u2242947 days ago1603

reply all(2)I'll reply

  • 数据分析师

    数据分析师2017-09-30 22:45:45

    What is the difference between var num1 = 10; and var num1 = "10";? - PHP Chinese website Q&A - What is the difference between var num1 = 10; and var num1 = "10";? - PHP Chinese website Q&A

    Take a look around Oh, study it.

    reply
    0
  • 阿神

    阿神2016-12-17 11:37:31

    你声明的变量var num1=10;里的10是number也就是数字,而var num='10'里的10是字符串

    可以使用后面章节中的将要介绍的typeof来输出下变量的类型,就会清楚了。

    复制下面两条语句到程序中运行看一下

    alert(typeof(num1));

    alert(typeof(num2));

    reply
    0
  • Cancelreply