The Startup
Published in

The Startup

3 Ways You May Don’t Know About Swap Two Numeric Variable Without a Temporary Variable

An interesting topic with little practical value.

Photo by s2 art on Unsplash

When we first learned programming, you must have written code that swapped the values of two variables. Now you can certainly accomplish this task very easily.

let a = 5
let b = 4

let tmp = a

a = b
b = tmp

--

--

--

Get smarter at building your thing. Follow to join The Startup’s +8 million monthly readers & +756K followers.

Recommended from Medium

ٍExiting from React Native application by double touch physical back button

Manipulating the DOM Through the Console with JavaScript

How to Easily Create Beautiful App Bars with Vuetify

How to enable TypeScript in an Angular template

BIRDZ’EYE: A Vue IDE

All you need to know about Splice and Slice

Dynamic text on image using LWC

Easily optimise your React (Native) Components rendering

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
bytefish

bytefish

Join Medium Membership through my referral link( https://bytefish.medium.com/membership) to motivate me create more high quality articles.

More from Medium

All Kinds of Project Managers I Got to Know on My Freelance Programming Projects

What does an $18 million dollar bug look like?

3 Neat Ec6 Tricks for Faster Coding

3 Tips Experienced Developers Use to Get Better Ideas