Javascript returning strange value

I was testing a function out to see what happens when it's parameters are `null` and decided to put an else statement with it. To my surprise, it did not log the parameters that I have passed, it's logging something else entirely. Maybe someone can shed some light on this, here's the code: function testing(o) { if (!o) { return "Sorry, looks like you need to pass an argument.." } else { return o; } } console.log(testing(02034)); //logs 1052 What's going on here?
It has to do with the number you put in. It started with a 0 which is in base 8.

以上就是Javascript returning strange value的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准