可能重复:
Why is JSHINT complaining that this is a strict violation?
在下面的缩写代码中,我使用此函数来确定函数参数是元素id还是对象。这样我总是可以使用元素。
function domPageFlip( some_var )
{
var select_element;
if( typeof ( some_var ) === 'string' ) // internally called
{
select_element = document.getElementById( some_var );
}
else // called by user event ( via event listener )
{
select_element = this;
}
jshint给出了可能的严格违规行为。如何编写代码,以免我发现此违规行为?