Is there any reason for which
eval("(function(x){return x*x;})")
doesn’t return a function with IE9?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It’s a bug in the JScript parser. It shouldn’t happen in IE9 unless you are in a Compatibility or Quirks mode.
IE8 misinterprets your function expression as a function declaration, causing it to fail to return anything. Previously mentioned in this question.
You can work around it using one of the other typical ways to unconfuse the JScript parser on what constitutes an expression vs a statement, eg: