I would use the unary plus operator to convert them to numbers first.
+num1 + +num2;
More Related Contents:
- Node.js bug ? function’s return value change when stored as variable
- Display attribute ‘Title’ of element/s in other element on Focus or Click
- Understanding unique keys for array children in React.js
- Is there any way to specify a suggested filename when using data: URI?
- How to add conditional attribute in Angular 2?
- Firestore: Multiple conditional where clauses
- valueOf() vs. toString() in Javascript
- How to copy JavaScript object to new variable NOT by reference? [duplicate]
- How to get the focused element with jQuery?
- Chrome can’t load web worker
- Development server of create-react-app does not auto refresh
- Is there an easy way to reload css without reloading the page?
- Typescript – Extending Error class
- How can val() return Number?
- Facebook “Like” button callback
- Convert inline SVG to Base64 string
- Showing alert in angularjs when user leaves a page
- How do I split a string by whitespace and ignoring leading and trailing whitespace into an array of words using a regular expression?
- How to run html file on localhost?
- Using Matter.js to render to the DOM or React
- Array.includes() to find object in array
- Javascript RegExp for splitting text into sentences and keeping the delimiter
- How to download PDF automatically using js?
- How to add validation/restrictions for HTML5 date field without jquery/javascript
- Creating an array consisting of the largest values of each sub-array does not work as expected
- Image Manipulation – add image with corners in exact positions
- How can I pass a reference to a function, with parameters? [duplicate]
- Javascript – Template Strings Don’t Pretty Print Objects
- Destructuring of es6 but passing dynamic variable
- Execute JS code after pressing the spacebar