10 Lesser-Known JavaScript Tips and Tricks for Advanced Web Developers

I bet you donā€™t know tip #2, JavaScriptā€™s ~~ operator

Dr. Derek Austin šŸ„³
Just JavaScript tutorials
5 min readAug 6, 2023

--

Get ready to feel the burn of JavaScript knowledge. It burns so good! Photo by Shaun Salmon on Unsplash

1. Exploit Destructuring for Multiple Returns

Destructuring is a nifty tool to unpack values from arrays or properties from objects into distinct variables. But did you know you can also use destructuring to effectively return multiple values from a function?

function getRaccoonStats() {
const name = "Rascal"
const weight = "15 lbs"
const age = "3 years"

return { name, weight, age }
}

const { name, weight, age } = getRaccoonStats()
console.log(`Meet ${name}, a ${weight}, ${age} old raccoon šŸ¦.`)

2. Double Tilde (~~) for Quick Floor Division

--

--

Dr. Derek Austin šŸ„³
Just JavaScript tutorials

Career advice, film reviews, writing tips, and coding with JS / TS, React & Git. Bio: Web dev since '05. BS & MS in Bioinformatics. Doctor of Physical Therapy.