以下代码传递JSLint:
var sGreeting = 'hello world';
switch (sGreeting)
{
case 'Hello world!':
var a = 'some a value';
break;
case 'Kamusta mundo!':
var b = 'some b value';
break;
case 'Salut le Monde!':
var c = 'some c value';
break;
default:
break;
}
Run Code Online (Sandbox Code Playgroud)
但是,一旦我将该代码放入函数中,JSLint就会抱怨我应该Combine ... with the previous 'var' statement.遵循JSLint,我将定义可能永远不需要使用的变量.我该如何处理这个问题?这是JSLint错误后面的代码:
function foo()
{
'use strict';
var sGreeting = 'hello world';
switch (sGreeting)
{
case 'Hello world!':
var a = 'some a value';
break;
case 'Kamusta mundo!': …Run Code Online (Sandbox Code Playgroud)