jsLint错误:“somefunction()在定义之前使用” [英] jsLint error: “somefunction() was used before it was defined”

查看:96
本文介绍了jsLint错误:“somefunction()在定义之前使用”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么JSLint会抱怨某些东西是否使用了尚未定义的函数?关键是该函数已定义 - 如果该函数调用该函数,该函数存在且事情将起作用。

Why does JSLint complain if something uses a function that hasn't been defined already? The point is that the function is defined -- and if that something calls that function, that function exists and things will work.

看看下面的代码:

function foo()
{
   // calls bar()
};

function bar()
{
   // calls foo()
};

没有办法以这样的方式组织2个方法,这样可以使JSLint满意。我该如何处理这个问题?

There is no way to organize the 2 methods in such a way that it would make JSLint happy. How do I deal with this issue?

推荐答案

看到这个答案:

与JS竞争在使用之前使用过和Titanium开发人员

基本上,如果你使用 foo = function(){...} 表单,您可以在顶部声明 var foo,bar; 以避免JSLint错误。

Basically, if you use the foo = function() { ... } form, you can declare var foo, bar; at the top to avoid the JSLint errors.

这篇关于jsLint错误:“somefunction()在定义之前使用”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆