나는 코딩 다음JSLint가 "typeof ... = undefined '"대신에 "=== undefined"를 사용하는 이유는 무엇입니까?
showTitles = (typeof showTitles !== 'undefined') ? showTitles : 'Y';
showSelectGroup = (typeof showSelectGroup !== 'undefined') ? showSelectGroup : 'Y';
을하지만 JSLint가 말하는 :
Warning 3 JS Lint: Unexpected 'typeof'. Use '===' to compare directly with undefined.
가 어떻게 코드를 변경해야합니까?
showTitles = (showTitles === undefined) ? 'Y' : showTitles;
showSelectGroup = (showSelectGroup === undefined) ? 'Y' : showSelectGroup;
jslint를 사용하여 아마
나는 jslint에 대해 아무것도 모른다. 그러나 나는 이것을 할 것을 당신에게 말하는 것이라고 생각한다 :'(showtitles === undefined)'. – Travesty3
그것은 메시지에서 : 'Use'=== 'undefined와 직접 비교하기 위해서'라고 말합니다. –
'예기치 않은 'typeof''가 문제이며'! =='는 문제가 아닙니다. – Blazemonger