Functions within closure do not need to be declared before use -- not an error #47

Closed
davebalmer opened this Issue Feb 21, 2011 · 1 comment

Projects

None yet

2 participants

@davebalmer

Consider this contrived snippet from a method in an object literal:

draw: function(flag) {
    var flag = flag || false;

    inner();

    function inner() {
        console.log("Ellipse.draw()");
    }
}

This throws a jshint error, namely, using inner before its declaration. Technically, there is no error in JavaScript in this case, and it is very often convenient to put all of the "flow" for the parent function up top, with the inner functions declared blow (instead of the other way round). This is a feature, not a bug. :) Would remove this error case entirely since it's not an error, or make it an option you can turn on.

@valueof
Member
valueof commented Feb 21, 2011

This is a duplicate of #29.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment