

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to create many Javascript variables in a single statement?
Declarations in a single line is a better way than creating many JavaScript variables in a single statement. It would be easier to add, remove and update variables with this.
Let’s compare,
var one = "Demo One!"; var two = "Demo Two"; var three = 5; var four = 30;
Now, let’s add it in one statement and see what happens. Since the line length increases, we need to take it to the next line,
var one = "Demo One!", two = "Demo Two", three = 5; four = 30;
Definitely, the first method is easy, less confusing and should be preferred.
- Related Questions & Answers
- How to assign same value to multiple variables in single statement in C#?
- How to set two variables in a stored procedure with a single MySQL select statement?
- How to create JavaScript regexes using string variables?
- How to optimize many SELECTs in a single table in MySQL?
- How to alter multiple columns in a single statement in MySQL?
- How can I declare and define multiple variables in one statement with JavaScript?
- Create many JavaScript objects as the same type?
- How to print a string two times with single statement in Python?
- How to declare variables in JavaScript?
- How to name variables in JavaScript?
- How many ways are there to initialize the instance variables of a class in java?
- How to use single statement suite with Loops in Python?
- How to compare two variables in an if statement using Python?
- Using variables with MySQL prepare statement
- How to preserve variables in a JavaScript closure function?
Advertisements