前端JS代码: var conditons = []; var test1 = new Object(); test1.name="1"; test1.id="2"; var test2 = new Object(); test2.name="1"; test2.id="2"; conditons.push(test1); conditons.push(test2); $(function(){ $.ajax({ async:
1.将json对象转化为json字符串,再判断该字符串是否为"{}" var data = {}; var b = (JSON.stringify(data) == "{}"); alert(b);//true 2.for in 循环判断 var obj = {}; var b = function() {for(var key in obj) {return false;}return true; } alert(b());//true 3.jquery的isEm
对于确定JS内置对象类型,JS提供了typeof运算符,该运算符得到的结果为以下6种:number,boolean,string,function,object,undefined.不过对绝大多数对象而言,typeof都返回"object",无法确定具体的类型.我们使用一种函数Object.prototype.toString.call来判断 <script> var a = 1; console.log("a:"+typeof a); //number