随笔分类 - JS
摘要:1、代码 Math.ceil(Math.random()*10); // 获取从 1 到 10 的随机整数,取 0 的概率极小。 搜索 复制
阅读全文
摘要:1、代码 function A(targetMarker) { targetMarker.sgl_xxx.connect(function(deltx) { console.log(deltx); }); }
阅读全文
摘要:声明: var points= {}; 存: points.a='123'; points.b ='456';var p1 = 'c';points[p1]='789'; 结果points= {'a':'123','b':'456','c':'789'}; 取: var d = points['a'
阅读全文
摘要:1、代码 var x = 12; console.assert(x==12, "this will pass") console.assert(x>12, "this will fail") 第一个参数放我们希望成立的表达式,如果运行时不成立则打印这个异常,系统会将调用堆栈也打印出来。【QML中使用
阅读全文
摘要:1、typeof int a = 0; console.log(typeof a);//Number
阅读全文
摘要:1、定义 var Status = Object.freeze({ "Connecting":0, "Ready":1, "Loading":2, "Processing": 3 }); 2、使用 console.log(Status.Ready) // 1 console.log(Object.k
阅读全文
摘要:1、遍历 var json={ "name":"乔峰", "age":"10", "sex":"男" }; for(var key in json){ console.log(key+":"+json[key]); } 2、通过下表获取 var ViewType = { a: "a", b: "b"
阅读全文
摘要:var str = text_name.replace(/\ +/g,""); str = str.replace(/[\r\n]/g,"");
阅读全文
摘要:var str = text_name.replace(/\ +/g,""); str = str.replace(/[\r\n]/g,""); console.log(str);
阅读全文
摘要:1、var uiRecord: [];//QML语法 2、删除并返回最后一个元素 uiRecord.pop(); 3、清空所有 uiRecord.splice(0,uiRecord.length); uiRecord = []; uiRecord.length = 0; 4、删除第一个元素并返回 u
阅读全文