- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Can someone explain to me what the plus sign is before the variables in JavaScript?
The plus(+) sign before the variables defines that the variable you are going to use is a number variable.
In the below code, there is brief description about plus sign. Following is the code −
Example
var firstValue="1000"; console.log("The data type of firstValue ="+typeof firstValues); var secondValue=1000; console.log("The data type of secondValue ="+typeof secondValue); console.log("The data type of firstValue when + sign is used ="+typeof +firstValue); var output=+firstValue + secondValue; console.log("Addition is="+output);
To run the above program, you need to use the following command −
node fileName.js.
Output
Here, my file name is demo149.js. This will produce the following output −
PS C:\Users\Amit\JavaScript-code> node demo149.js The data type of firstValue =string The data type of secondValue =number The data type of firstValue when + sign is used =number Addition is=2000
Advertisements