- Trending Categories
- 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
What is the best way to initialize a JavaScript number?
The best way to initialize a number in JavaScript is to initialize variables while declaring them. Through this, you can easily avoid undefined values.
Example
You can try to run the following code to initialize a number −
<!DOCTYPE html> <html> <body> <script> var deptNum = 20, id = 005; document.write("Department number: "+deptNum); </script> </body> </html>
Advertisements