Home  >  Q&A  >  body text

布尔值和字符串是什么,为什么数值和布尔值不用加引号?

例如:var a = 123;       // 123是数值

var b = "一二三";    //"一二三"是字符串

var c=true;    //布尔值true(真),false(假)

其中,a变量存储的内容是数值;b变量存储的内容是字符串,字符串需要用一对引号""括起来,c变量存储的内容是布尔值(true、false)。


你的名字你的名字2863 days ago1826

reply all(2)I'll reply

  • 数据分析师

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

    What are Boolean values ​​and strings? Why don’t numbers and Boolean values ​​need quotes? -PHP Chinese website Q&A-What are Boolean values ​​and strings? Why don’t numbers and Boolean values ​​need to be quoted? -PHP Chinese website Q&A

    Please watch and learn.

    reply
    0
  • 阿神

    阿神2016-12-17 11:50:44

    在JavaScript中数据类型有:Undefined类型、Null类型、Boolean类型、Numeber类型、String类型、Object类型。

    1.布尔值是 Boolean 类型,只有两个值 true 和 false

    例子:

    var a = true;
    var b = false;

    字符串是 String 类型

    例子:

    var c = "你好";
    var d = ""; //表示空串

    2.数值和字符串不加引号,好比甲鱼的臀部 -- 规定~~~ 记着就好,如果想知道为什么可以看看《编译原理》

    reply
    0
  • Cancelreply