0

console.log(1 + '1' - 1)

crack this with details of every step

18th Feb 2024, 6:06 AM
Riaz Anwar
Riaz Anwar - avatar
5 ответов
+ 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
18th Feb 2024, 7:06 AM
Mihaly Nyilas
Mihaly Nyilas - avatar
+ 2
🇮🇩🇵🇰CyberSecure🇵🇰🇲🇨 console.log is in JS not Java
18th Feb 2024, 12:41 PM
A͢J
A͢J - avatar
+ 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
18th Feb 2024, 7:31 AM
Tibor Santa
Tibor Santa - avatar
0
What is it java or JS
18th Feb 2024, 11:39 AM
REdoZAk1k3
REdoZAk1k3 - avatar
0
Riaz Anwar , Please add a tag for 'javascript' or 'js'.
20th Feb 2024, 3:02 AM
Rain
Rain - avatar