Mathew Kleppin
JavaScript Anyone?
Variables
Programs made up of different things
Variables
Conditions
Collections
Loops
Functions
Classes
Used to track values as they change over the course of a program.
A symbol or set of symbols that can change value over time.
"String"
"Hello World!"
Number
42
Boolean
true
text = "Hello World"
count = 12
ugly = false'Character'
'H'
Double
42.215
firstInitial = 'M'
taxRate = 0.75A single line of instructions to follow
a = b * 2a and b are variables
2 is a literal value (it never changes)
* is an operator (it does a thing)
What can you do with numbers? Maths!
100 / 10 - 6
2 * (10 + 6)
a = 12
b = a * 3Special Numbers
NaN
Infinity
Text inside of quotes
"Welcome to monkey island"
'The Gorillas raped that girl'Your supposed to use single quotes for strings though...
'Thats what "she" said'
"Your 'elephant' is huge"Quotes inside of quotes
'Winter is \'comming\''
'Lorem ipsum dolor sit amet,\nconsectetur adipiscing elit.'Trailing backslash before quotes prevents excapes
Special characters inside of strings
\n creates a new line
Addings strings togeather (concatination)
'Hello' + ' ' + 'World'
a = 'Hello'
b = ' '
c = 'world!'
a + b + cSingle Line
//this won't be seen by program
Comment Block
/* Comment Blocks Need Closing Tags */
firstInitial = 'M' //for mathew
/*
This Next Part calculates Taxes
*/
taxRate = 0.75 Go to the next line
;
firstInitial = 'M'
secondlineVariable = 10;
{
indentAThing = 11
intentSecondThing = 12;
}Code Block
{
// some code here ...
}
Read as
firstInitial = 'M'secondlineVariable = 10;
{indentAThing = 11intentSecondThing = 12;}firstInitial = 'M';
secondlineVariable = 10;
{
indentAThing = 11;
intentSecondThing = 12;
}Read as
firstInitial = 'M';
secondlineVariable = 10;
{indentAThing = 11;
intentSecondThing = 12;}Minus
-
Plus
+
a = 10 - b
b = c + 7Double Minus
--
Double Plus
++
a = 10
a++
a == 11 //truea = 10
a--
a == 9 //trueMultiplication
*
a = 10 * bDivision
/
a = 10/5
a == 2
Equals
=
a = 10
b = c + 1
Double Equals
==
Checking Equality
a = 10
a++
a == 11 //truea = 10
a--
a != 10 //true'Assignment'
Not Equals
!=
Checking Inequality
a = 10
a++
a != 11 //falsea = 10
a--
a == 9 //trueTriple Equals
===
a = 10
a === "10" //false
a = 5
a === 5 //true"Hello" !== "hello" //true
"true" !== false //truea = "10"
a !== 10 //trueMatches Type
tax = "false"
tax === true //false
tax = 0
tax == false //trueTriple Not Equals
!==
By Mathew Kleppin
A quick introduction into variables