Posts

Showing posts with the label variables

JavaScript for Beginners - Basic Concepts (Variables) (P: V)

Image
Variables Variables are containers for sorting data values. The value of a variable can change throughout the program. In JavaScript use the var keyword to declare a variable: In the example above, the variable x is assigned the value 10. Note: JavaScript is case sensitive. For example, the variables lastName and lastname , are two different variables. The Equal Sign In JavaScript, the equal sign (=) is called the “ assignment” operator, rather than an “equal to” operator. For example, x = y will assign the value of y to x . Let’s assign a value to a variable and output it to the browser Result:   Note: A variable can be declared without a value. The value might require some calculation, something that will be provided later, like user input. A variable declared without a value will have the value undefined Using variable is useful in many ways. You might have a thousand lines of code that may include the variable x. When you change the value of x one time, it will automati...