@kungfuboy
2016-12-30T03:49:53.000000Z
字数 2018
阅读 1131
未分类
// 奇酷消息盒子航班页面——flight.jsonload = function() {···try {if (flight_num == "null" || flight_num == "NULL") {flight_num = flight_numArr[1].replace(" ", "").replace(" ", "");} else {flight_num = flight_numArr[0].replace(" ", "").replace(" ", "");}} catch (e) {// TODO: handle exception}···try {flight_from_time = window.injs.getConfigByKey('flight_time');flight_to_time = window.injs.getConfigByKey('arrive_time');flight_to_date = window.injs.getConfigByKey('arrive_date');} catch (e) {// TODO: handle exception}···}
第14行和第25行,catch中并没有代码,依旧保留着try。
//850ms!function() {//无 try catch 的情况耗时var t = new Date();//耗时代码开始for (var i = 0; i < 100000000; i++) {var p = i % 2;}//耗时代码结束document.write(new Date() - t);try{}catch(e){}}();//140ms!function() {//无 try catch 的情况耗时var t = new Date();//耗时代码开始for (var i = 0; i < 100000000; i++) {var p = i % 2;}//耗时代码结束document.write(new Date() - t);}();//修改后!function() {!function() {//无 try catch 的情况耗时var t = new Date();//耗时代码开始for (var i = 0; i < 100000000; i++) {var p = i % 2;}//耗时代码结束document.write(new Date() - t);}();try{}catch(e){}}();
function isNull(data){return (data == "" || data == undefined || data == null || data == 0) ? true : false;}···if(!isNUll(data)) {···}
其实,这样就可以了:
!!data
PS: 字符串中的0无法判断
面向全局写法:
window.onload = {init();}function init() {methon1();methon2();methon3();}function methon1(){}function methon2(){}function methon3(){}
普通的面向对象写法:
function App() {}App.prototype.init = function() {}App.prototype.render = function() {}var app = new App();app.init();app.render();
从jQuery里面学习到的写法:
window.onload = function(){App();}function App() {return new App.prototype.init();}App.prototype.init = function() {}App.prototype.init.prototype = App.prototype;
//jquery$(el).css("width");//普通的jsgetElementById('el').style.width;//jsgetComputedStyle(el)["width"];
//流量充值页面if ($("#phone").length > 0) {$("#phone").bind("keyup", function(e) {var t = this.value.length;if(phonenum == $("#phone").val()){return ;}Object.defineProperty(obj, key, {enumerable: true, //属性是否可枚举configurable: true, //属性是否可配置get: function() {},set: function() {}});
https://github.com/search?p=1&q=stars%3A%3E1&s=stars&type=Repositories