eval(0+'1'+3) => 11 (???)
When eval(0+’1′) is executed =>1. Iam expecting that 0+’1′ will give me 1 & 3 will be considered as string & o/p => 13. But, why is that not happening?
whereas
eval(1+'1'+3) => 113
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.
You are creating the string “013”, which is evaluated as a JavaScript integer literal. Integer literals starting with
0are interpreted base 8 (octal), so your number is 8 + 3, which is 11.Only integer literals starting with a non-zero digit are interpreted base 10.