Literals are fixed values of either numbers (with or without decimals), or strings.
// numerical literals 3.14; 48; // Strings "Hello World!"; 'Hello Mars!';
Literals won't do much on its own, so let's take a look at variables, which are containers that can store literals.
Variables store data values such as literals. They can also be set to expressions, which are evaluated and placed into the variable.
To define a variable, we use the
var keyword with the assignment operator
// Initialize variable count and set it to 0 var count = 0; // Or just initialize the variable var count;
In the second initialization, the variable
count is initalized to
You can also declare multiple variables while using the
var keyword just once.
var price = 5, quantity = 23, total = 50; var price, quantity, total;
var keyword. We'll talk about the different data types and typecasting in the next section.
Here are some guidelines to follow when assigning a variable name:
When deciding on a variable name, it's important to be clear and descriptive. Names like
pre are too short and don't convey any information.
Variables of more than one word should have a upperCamelCase format. This means that the first word is all lowercase, and any subsequent words have their first letters capitalized. For example, a variable that holds the number of remaining books would look like
Relieve spasms, tight muscles, trigger points and pressure points with the Body Back Buddy! This trigger point massage is designed to help you self-message any area of your body - especially those that are hard to reach. Keeping your muscles relaxes and out of contraction is importan in helping to reduce pain and prevent muscle injury.$ Check price
Want your web site to display more quickly? This book presents 14 specific rules that will cut 25% to 50% off response time when users request a page. Author Steve Souders, in his job as Chief Performance Yahoo!, collected these best practices while optimizing some of the most-visited pages on the Web.$ Check price