zoukankan      html  css  js  c++  java
  • js数据类型

    • 字符串(String)
    • 数字(Number)
    • 布尔(Boolean)
    • 数组(Array)
    • 对象(Object)
    • 空(Null)
    • 未定义(Undefined)
    var num = 1,
        boo = true,
        aa = null,
        bb,
        str = 'mary', 
        arr = [1, 2, 4, 8],
        obj = {
            'name': 'aa'
        },
        arrNew = new Array([1, 2, 3]),
        strNew = new String([1, 2, 3]);
    
    //typeof 检测变量的类型  
    console.log('Number:', typeof num);     // number
    console.log('Boolean:', typeof boo);    // boolean
    console.log('Undefined:', typeof bb);   // undefined
    console.log('String:', typeof str);     // string
    
    console.log('Null:', typeof aa);    // object
    console.log('Array:', typeof arr);  // object
    console.log('Object:', typeof obj); // object
    console.log('new Array():', typeof arrNew); // object
    console.log('new String():', typeof strNew);    // object
    
    // nullundefined 比较
    console.log(null == undefined); // true
    console.log(null === undefined);    // false

    1、new 关键字声明的变量,得到的 都是一个对象
    2、null:表示什么也没有,一个空对象引用
    undefined:表示一个没有设置值的变量

  • 相关阅读:
    jsf web.xml配置
    JSF中Filter的实现
    转码
    facelates标签
    jsf学习笔记注解
    date工具类
    js秒读功能
    w3c document 与 dom4j document转化工具类
    jsf学习笔记ui
    jsf学习笔记拦截器
  • 原文地址:https://www.cnblogs.com/Zting00/p/7497652.html
Copyright © 2011-2022 走看看