On Github pferdefleisch / IntroJavascriptPresi
Created by aaron cruz / @mraaroncruz
Programming is basically
A variable is a named place where you can store information you can use later
Storing numbers for addition
An ordered list of data that can be accessed by index. Index starts at zero.
List of users; Temperatures for the week
var users = ["Bob", "Lisa", "Aaron"]; alert(users[0]) // => alerts "Bob"
A data structure based on keys and values. Keys must be strings but values can be any of the other Types.
Any complex data structure.
data returned from external service e.g. Twitter, Weather
var bob = { firstName: "Bob", lastName: "Smith", phone: "333444343"}; alert(bob.firstName); // => alerts 'Bob'
A piece of code that performs a task
Adding two numbers together; Trahsforming a list of data.
function addTwo (n) { alert(n + 2) } addTwo(4); // => alerts 6
or return a value
function addTwo (n) { return n + 2; } var newValue = addTwo(4); alert(newValue); // => alerts 6
A variable is a named place where you can store information you can use later
takes as arguments
Initial value It will keep looping until this evalutes to false What to change (increment or decrement the counter)for (var i = 0; i < 10; i += 1) { alert(i); }
Storing numbers for addition
Your code making decisions
If this is true, then do something, otherwise do something else
Act on received data, only if you really received data
var n = 4; if (n === 3) { alert("there is a problem here"); } else { alert("At least it doesn't equal 3" }
// save the "Hello World!" string in a variable named 'hello' var hello = "Hello World!"; // built in JavaScript 'alert' pops up dialog in browser with it's argument alert(hello);
https://developer.mozilla.org/en/docs/JavaScript
https://developer.mozilla.org/es/docs/JavaScript