Avinashd Posted on Dec 27, 2024 Js in bits - 8.9(basic operators) #javascript #tutorial #learning #interview Learning js should be fun. It is fun if it's easy. I tried my best in writing this, to understand it the easy way. Practise Exercises Let your thoughts flow.... Leave y'r thoughts.... Top comments (2) Subscribe Submit Preview Dismiss Collapse Expand Marcin Rybacki Marcin Rybacki Marcin Rybacki Follow Joined Aug 7, 2023 • Dec 27 '24 Dropdown menu Copy link Hide All is quite logical here. Three observations here. There are operators that only exist in math are (*, /, -). They try to convert literal into number and calculate. If it's not possible, than NaN Whether '+' is concat or math operator depends on the type of left argument. There's a curious case of null converted to 0, but undefined converted to NaN, also ' \t \n' converted to 0 Collapse Expand Avinashd Avinashd Avinashd Follow Joined Jun 6, 2018 • Dec 27 '24 Dropdown menu Copy link Hide 1, Yes correct 2, + can do 2 things, concat or addition. addition if both operands are numbers concat if one of them is a string This clears out any confusion: dev.to/avinashd10/js-in-bits-82bas... 3, Math conversion rules gives more clarity dev.to/avinashd10/js-in-bits-7type... Happy learning. Code of Conduct • Report abuse
Top comments (2)
All is quite logical here. Three observations here.
1, Yes correct
2, + can do 2 things, concat or addition.
addition if both operands are numbers
concat if one of them is a string
This clears out any confusion:
dev.to/avinashd10/js-in-bits-82bas...
3, Math conversion rules gives more clarity
dev.to/avinashd10/js-in-bits-7type...
Happy learning.