0
console.log(1 + '1' - 1)
crack this with details of every step
5 Respostas
+ 5
the result will be 10.
why?
first 1 is an integer, but if you add a string, then it's concatenated with the '1';
after that you subtract an integer, so it converts to number....
javascript is not a typed language, this is the main reason
+ 2
🇮🇩🇵🇰CyberSecure🇵🇰🇲🇨
console.log is in JS not Java
+ 1
Javascript has a lot of complicated, and sometimes unreasonable rules for implicit type coercion. Writing code like this, and relying on these rules, often makes your code very difficult to read, and the result hard to predict.
If you want to learn more, here is an excellent summary.
https://dev.to/promisetochi/what-you-need-to-know-about-javascripts-implicit-coercion-e23
0
What is it java or JS
0
Riaz Anwar ,
Please add a tag for 'javascript' or 'js'.