In JavaScript, variables are used to store data that will be used in multiple places. This allows the data to be kept in one place for ease of change.

Variables can be declared using three different methods: var, let, and const. See the JavaScript resource on var vs. let vs. const to see how and when each should be used.

var

“var” is typically used when a value may change over time.

				
					var x = 5;
				
			

let

“let” is typically used when a value is restricted to the block { } of code where it is created.

				
					let x = 5;
				
			

const

“const” is typically used when a value CANNOT change over time.

				
					const first_name = 'Johnny';