(true + true === 2)
Happens because of type coercion occuring right at "+ true" and also because there is more than one equal (not an assignement).
In the same way, if you need a date epoch interger, instead of using
new Date().getMilliseconds()
you can just do
+new Date()
Plus at the beginning of the statement forces type coercion into number.
Dr. Axel Rauschmayer's book Speaking JS is amazing and full of well written explanations. Including what I'm outlining here.
Thanks, going to fix that
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Happens because of type coercion occuring right at "+ true" and also because there is more than one equal (not an assignement).
In the same way, if you need a date epoch interger, instead of using
you can just do
Plus at the beginning of the statement forces type coercion into number.
Dr. Axel Rauschmayer's book Speaking JS is amazing and full of well written explanations. Including what I'm outlining here.
Thanks, going to fix that