How does eval overhere or how does it behave?
source link: https://www.codesd.com/item/how-does-eval-overhere-or-how-does-it-behave.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
How does eval overhere or how does it behave?
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
You are creating the string "013", which is evaluated as a JavaScript integer literal. Integer literals starting with 0
are 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.
Related Articles
Why does `-lt` behave differently for characters and strings?
Clojure - Why does it behave differently with a list than a vector?
How does __eq__ behave in Python and in what order?
How does Static behave here in asp.net?
How does locking behave in .net?
Code Ruby that does not work. How comes it? I have included Enumerable, implemented each but reject does not behave as I expect
perl: how does "$ 1" behave in a loop?
Does anyone know how this option behaves as Anchor Tag?
Question about the example of Apple's LazyTableImages - Does not behave exactly as the application
Task.Delay () does not behave as expected
Bootstrap modal does not behave as modal
The recursive function does not behave properly
The URL does not behave as expected in Zend Framework
& Lt; Select & gt; Width in IE does not behave as in other browsers
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK