Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Avinashd
Avinashd

Posted on

     

Js in bits - 8.9(basic operators)

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....

Image description

Leave y'r thoughts....

Top comments(2)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss
CollapseExpand
 
rybama profile image
Marcin Rybacki
  • Joined

All is quite logical here. Three observations here.

  1. 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
  2. Whether '+' is concat or math operator depends on the type of left argument.
  3. There's a curious case of null converted to 0, but undefined converted to NaN, also ' \t \n' converted to 0
CollapseExpand
 
avinashd10 profile image
Avinashd
  • Joined

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.

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

  • Joined

More fromAvinashd

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp