1

Line 576 of jQuery 1.7rc1 is:

return (new Function( "return " + data ))();

Now jshint complains with the warning

The Function constructor is eval.

What does this error mean? Why did the jQuery people write this line the way it is?

2
  • 1
    There is no set of rules how to write code. JSHINT/JSLINT is a set of guidelines for good and proper code construction. Do you get an error, or is out of interest? :) Commented Oct 28, 2011 at 22:33
  • Well the jQuery code produces a jshint warning. It's out of interest that I'm asking here. Commented Oct 28, 2011 at 22:34

1 Answer 1

4

Since eval is evil and the Function constructor uses eval to create the new Function, jshint doesn't like it. JQuery is using it to parse JSON for older browsers that don't natively support JSON.parse().

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.