In JavaScript, a variable is anything that can vary. It stores a data value that can be changed later on. A variable name in JS must start with either a letter, an underscore, or a dollar sign; it can not start with a number. To initialize a variable, one could use the equals sign as an assignment operator (=) to set the variable name equal to a piece of data i.e. a number, boolean, string, array, object, function, etc. Initialization is when you assign a value to a variable, whereas declaration is when no value is assigned to the variable, only the name and type is defined. Arithmetic Operators in JS would include the standard addition, subtraction, multiplication, and division as well as incrementing, decrementing, and exponentiation. One could use the prompt() method to open a client side window to take input from a user.
Leave a Reply
You must be logged in to post a comment.