🤯 Mind Blown! How on earth did I not know this!!! DID YOU KNOW? In JavaScript, adding a unary plus (+) in front of a value is the quickest way to coerce it to a number. It's super handy for quick, clean conversions. This tiny operator saves you typing Number() and works on almost everything 💡 Quick Win with Inputs This trick shines when dealing with HTML inputs, which always return strings. Using the unary plus and the OR operator (||) guarantees you get a number or a safe default. Tiny operator, big convenience for keeping your types clean. What other hidden JavaScript gems should we uncover next? #JavaScript #React #WebDev #Frontend #SoftwareEngineer #FrontEndDeveloper #Tips #OpenToWork #jobSearch #Hiring
This kind of works, but BigInts will throw a TypeError due to the loss of precision and it's not very legible/predictable
Amazing insights! It's fun to find hidden code tricks Elham Poshtiban 👩🏼💻
this is basically the "+string" conversion thing in javascript, if you try a string value instead of "e.target.value" you will get the same result.