我有一个jQuery插件。其中一个选项是用于动画的缓动方法。在继续使用指定的宽松方法调用$.animate(...)函数之前,我希望能够检查是否定义了宽松方法。如下所示:
var easingMethod = option.easing;
if (!IsDefined(easingMethod)) easingMethod = 'linear';什么是IsDefined()函数?
除了typeof(easingMethod)==='string',我可以做if (typeof(easingMethod)==undefined)。我想的更多的是
function isDefined(s) {
// If a method named 's' is defined, return true, else false
}我不知道该怎么做。
发布于 2013-02-24 18:58:01
这个怎么样?
function isDefined(s) {
return $.easing.hasOwnProperty(s);
}https://stackoverflow.com/questions/15051026
复制相似问题