<script>
alert("abc"+1+2)
alert(1+2+"abc")
</script>
The first line is to add a number from the letter + number (when viewed as a whole) It's abc12.
The second line is a number plus a number plus a letter Is it 3abc?
Can I understand that the value varies depending on the location of the character?
It's simple. I'm confused.
javascript
This is due to the priority of the operator.
If only added, the left side is calculated first, so it depends on whether the left side comes first with a string + string (or another type of value that can be converted into a string) or a number + number.
© 2024 OneMinuteCode. All rights reserved.