var num1 = 10; 和var num1 = "10"; 有什么区别?
phpcn_u224
phpcn_u224 2016-12-17 11:33:04
0
2
1584

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

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

phpcn_u224
phpcn_u224

reply all(2)
数据分析师

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.

阿神

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

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

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

alert(typeof(num1));

alert(typeof(num2));

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template