GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — javascript-2/basics/variables.md at master · ufo-github/javascript-2

Expand file tree

/

variables.md

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
50 lines (35 loc) · 1.26 KB
/

variables.md

Copy path

File metadata and controls

50 lines (35 loc) · 1.26 KB
Raw
Copy raw file
Download raw file
Edit and raw actions

Variables

The first step towards really understanding programming is looking back at algebra. If you remember it from school, algebra starts with writing terms such as the following.

3 + 5 = 8

You start performing calculations when you introduce an unknown, for example x below:

3 + x = 8

Shifting those around you can determine x:

x = 8 - 3
-> x = 5

When you introduce more than one you make your terms more flexible - you are using variables:

x + y = 8

You can change the values of x and y and the formula can still be true:

x = 4
y = 4

or

x = 3
y = 5

The same is true for programming languages. In programming, variables are containers for values that change. Variables can hold all kind of values and also the results of computations. Variables have a name and a value separated by an equals sign (=). Variable names can be any letter or word, but bear in mind that there are restrictions from language to language of what you can use, as some words are reserved for other functionality.

Let's check out how it works in Javascript, The following code defines two variables, computes the result of adding the two and defines this result as a value of a third variable.

var x = 5;
var y = 6;
var result = x + y;
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.