2
我有一个jQuery插件。其中一个选项是用于动画的缓动方法。我希望能够检查是否定义了缓动方法,然后继续并使用指定的缓动方法调用$.animate(...)
函数。像这样:如何检查是否定义了特定的jquery-easing方法?
var easingMethod = option.easing;
if (!IsDefined(easingMethod)) easingMethod = 'linear';
什么是IsDefined()
函数?
我可以做if (typeof(easingMethod)==undefined)
,但typeof(easingMethod)==='string'
。我想更多的沿线
function isDefined(s) {
// If a method named 's' is defined, return true, else false
}
而我不知道该怎么做。
感谢。这似乎工作。我应该准备好更多关于'hasOwnProperty(s)'的内容。 – 2013-02-24 11:04:33