06-数据类型

  js数据类型

      一. 基本数据类型-7种

         1 number 数字类型

         2 string 字符串

         3 boolean 布尔型

         4  null  空值

         5  未赋值的变量默认值是undefined,类型是undefined

        6 symbol 产生独一无二的值

        7 bigint

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    // js数据类型
    //  1 基本数据类型-7种
    //  2 引用数据类型-如数组、对象...
    const age  = 18
    console.log(typeof  NaN);  // NaN not a number
    console.log(typeof age); // 1 number 数字类型 
    const str  = 'hello' //  '' 单引号
    const str2 = "hello"
    const str3  = `hello` // 模版字符串 支持换行 支持表达式
    console.log(typeof  str3); // 2 string 字符串
    const str4 = 'china'
    console.log(str + 'str4');  // hellostr4
    console.log(`hello${str4}`); // 'hello' + str4
    // 控制台输出我今年18岁了
    console.log('我今年'+age+'岁了');
    console.log(`我今年${age}岁了`); // 模版字符串拼接
    const  str5  = "hello 'china'"
    console.log(str5);
     console.log('===========');
     const flag =  true
     const flag2 = false
     console.log(typeof flag);//  3 boolean 布尔型
     let school  //  4  未赋值的变量默认值是undefined,类型是undefined
     console.log(school, typeof school); // undefined 'undefined'
     let obj = null  // 5  null  空值
     console.log(typeof obj);  // object
     let s = Symbol() // 产生独一无二的值 
     console.log(typeof s);  // 6 symbol 
     const  num =  12n 
     console.log(typeof  num);  // 7 bigint
  </script>
</body>
</html>

      二. 引用数据类型-如数组、对象...

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值