How to convert a string type into a number type using Unary Operators

A unary operator is an operation with only one operand.

Plus sign (+) can function as an Addition Operator and also as a Unary Version in Javascript Objects.

As an arithmetic addition operator: It takes numerical values (literals or variables) as their operands and return a single numerical value.

Both + and — operators have unary versions, where they operate only on one variable.
When used in this fashion, + returns the number representation of the object, while — returns its negative counterpart

The unary plus operator converts its operand to Number type.

The unary negation operator converts its operand to Number type and then negates it.

On desk for javascript
Photo by Federica Galli on Unsplash

--

--

--

think&code. Also an occasional G(Foodie)OAT: https://www.instagram.com/anaikoki/

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

ddclient.conf with dig dns-o-matic

JavaScript: Merge Sort Algorithm

storm looper

Angular 6 Animations From Scratch

API Endpoint in Express

React JS with Apache Thrift API

Calculator with Javascript

AHHA this is a class asignment

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
Anna Ikoki

Anna Ikoki

think&code. Also an occasional G(Foodie)OAT: https://www.instagram.com/anaikoki/

More from Medium

The Document Object Model, Counting Function Calls, and HTML5/CSS3

Your own fetchAll API w/o Promise

Stack Data Structure and What does it have to do with JavaScript?

Construct a binary tree from given multi-dimensional array