js中的数据类型、非运算、等值判断
来源:互联网 发布:js点击跳转到指定页面 编辑:程序博客网 时间:2024/05/17 08:06
1 js的数据类型
//console.log(typeof arr),输出变量的类型var arr; //undefinedarr = function foo() { //function // body...}arr = []; //objectarr[0] = 1; //objectarr = null; //objectarr = new Date(); //objectarr = "test"; //stringarr = 1; //number
2 js空值的非运算与等值判断
var obj1;var obj2 = null;var obj3 = "";var obj4 = [];//非运算console.log(!obj1); //trueconsole.log(!obj2); //trueconsole.log(!obj3); //trueconsole.log(!obj4); //false,空数组应该判断长度console.log(obj4.length); //0//等值判断console.log(obj1 == obj2); //true, undefinded = nullconsole.log(obj1 === obj2); //false, undefinded不严格等于nullconsole.log(obj2 == null); //true, null = nullconsole.log(obj3 == ""); //trueconsole.log(obj4 == []); //false, 空数组not equal []
3 array和object的等值判断
var arr1 = [1, 2, 3];var arr2 = [1, 2, 3];console.log(arr1 == arr2); //falseconsole.log(arr1 == [1, 2, 3]); //falsevar obj1 = {"a" : "1"};var obj2 = {"a" : "1"};console.log(obj1 == obj2); //falseconsole.log(obj1 == {"a" : "1"}); //false
阅读全文
0 0
- js中的数据类型、非运算、等值判断
- 判断js中的数据类型
- 判断js中的数据类型
- 【JS数据类型】JS中的判断数据类型函数
- 如何判断js中的数据类型
- 何判断js中的数据类型
- 如何判断js中的数据类型
- 如何判断js中的数据类型
- 如何判断js中的数据类型
- 如何判断js中的数据类型
- 如何判断js中的数据类型
- 如何判断js中的数据类型
- 如何判断js中的数据类型
- 如何判断js中的数据类型
- 如何判断js中的数据类型
- 如何判断 js 中的数据类型
- javascript等值运算
- 等值链接和非等值链接
- 支付宝原理
- 修改程序标题
- StringUtil类的常用方法
- 3-5 学生成绩统计
- NLP
- js中的数据类型、非运算、等值判断
- oxc000014c解决方法
- 51nod 1418放球游戏(逻辑简化)
- HTML5按钮特效
- 八-1 使用设备模式模拟移动设备
- 机器学习——标准化/归一化的目的和作用
- 1003. Emergency (25)
- Android加入热修复报java.lang.UnsatisfiedLinkError: 解决方法
- eclipse自动生成变量名快捷键