View on GitHub

reading-notes

Reading notes for Code 102.

Javascript

How to Use Objects and Methods

Statements

-a script will have to store information to do its job, use variables to do so

Variables and how to declare them

Data types

shorthands for creating variables

  1. variables declared then values are assigned in statement
    var price =5;
    var quantity =14;
    var total =price*quantity;
    
  2. three variables are declared on the same line, then values are assigned to each
 var price, quantity, total; 
price =5;
quantity= 14;
total =price * quantity;
  1. two variables are declared and assigned values on the same line. Then one is declared and assigned a value on the next line
var price =5, quantity =14;
var total = price * quantity;

Changing the value of a variable

Important Rules for Naming Variables

  1. the name must start with a letter, $, or _, and it cannot start with a number
  2. the name can contain these afterwords, but you must not use a - or . in a variable name.
  3. you cannot use keywords or reserved words.
  4. all variables are case sensitive
  5. use a name that describes the kind of info that the variable stores to add js file into html –>

<= Back