JavaScript Lessson 3

JavaScript Syntax

Lesson 2 Lesson 4


var Statement:

  • The var statement declares a variable.
  • If you put a number in quotes, it will be treated as a text string.
  • In programming, text values are called strings.
  • Strings variables in javascript can be included in single quotes or double quotes.

Strings are text, written within double or single quotes:

  • Single quotes: document.getElementById('ID').innerHTML = 'Text';
  • Double quotes: document.getElementById("ID").innerHTML = "Text";
  • The best to use the quotes is:
    • Using Single quotes for the selectors.
    • Using Double quotes for the variables.
      Like: document.getElementById('ID').innerHTML = "Text";