From aa20aa950d30572122240a5ecb4451803f8fe856 Mon Sep 17 00:00:00 2001 From: Wang Yuxing <396276123@qq.com> Date: Thu, 10 Jul 2014 10:51:32 +0800 Subject: [PATCH] a problem : undefined var swipe=(function(me){ var test = 1; var undefined = 1; // compare following situations: me.test1 = (test !== undefined); //false me.test2 = (typeof test !== 'undefined'); // true return me; }(swipe||{}) ); alert(swipe.test1); alert(swipe.test2); --- swipe.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/swipe.js b/swipe.js index 8b29717..d0ed89f 100644 --- a/swipe.js +++ b/swipe.js @@ -20,7 +20,7 @@ function Swipe(container, options) { touch: ('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch, transitions: (function(temp) { var props = ['transitionProperty', 'WebkitTransition', 'MozTransition', 'OTransition', 'msTransition']; - for ( var i in props ) if (temp.style[ props[i] ] !== undefined) return true; + for ( var i in props ) if (typeof temp.style[ props[i] ] !== 'undefined') return true; return false; })(document.createElement('swipe')) }; @@ -32,7 +32,7 @@ function Swipe(container, options) { options = options || {}; var index = parseInt(options.startSlide, 10) || 0; var speed = options.speed || 300; - options.continuous = options.continuous !== undefined ? options.continuous : true; + options.continuous = typeof options.continuous !== 'undefined' ? options.continuous : true; function setup() {