JavaScript eval() function on a number preceded by four "0"s. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

JavaScript eval() function on a number preceded by four "0"s.

Like, eval(000026)= 24. How come? https://code.sololearn.com/WnzE9nnXceG7/?ref=app

1st Feb 2020, 4:32 PM
Nor'wester 🌪️ 🇧🇩 (INACTIVE)
Nor'wester 🌪️ 🇧🇩 (INACTIVE) - avatar
4 Answers
+ 1
Nor'wester , numbers starting with 0 are considered octal numbers. So when you convert octal to decimal that's the result 🐱
1st Feb 2020, 5:21 PM
TheWh¡teCat 🇧🇬
TheWh¡teCat 🇧🇬 - avatar
+ 1
Well, there goes my calculator.
1st Feb 2020, 6:01 PM
Nor'wester 🌪️ 🇧🇩 (INACTIVE)
Nor'wester 🌪️ 🇧🇩 (INACTIVE) - avatar
+ 1
not necessarily just work around it... Nor'wester that is what we all learn to do... when there are potential risk.
1st Feb 2020, 6:03 PM
BroFar
BroFar - avatar
0
It has come to my attention that it may not be wise to use the eval() in Javascript and would discourage it's use... https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval
1st Feb 2020, 5:46 PM
BroFar
BroFar - avatar