Share
Embed
Transcript
38 slides
-
FRONT END JavaScript, HTML, and CSS are often referred to
as the “front end” or “client” side of websites. Browsers render these languages to display the interface of the website to the user. Server technologies like PHP, Ruby, Python, etc. make up the “back end” or “server” side of websites. -
WHAT’S IT GOOD FOR? JavaScript is like the duct tape
of the Internet. It can be used for pretty much anything. It gives you extremely powerful access to animation, retrieving data from servers after the page has loaded, connecting to 3rd party APIs like those from your favorite social networks. -
JQUERY jQuery is a JavaScript library that makes a lot
of things much easier to write. It is used by about 61% of the top 100,000 sites. One of it’s big advantages is being able to use CSS selectors to access elements on the page. It also simplifies working with user interactions. It isn’t all rainbows and smiley faces, but that’s a talk for another time. -
NODE.JS Node.js is a server side technology that runs on
JavaScript. Remember how we said JavaScript can pretty much be used for anything? -
LET’S START WITH THE FUNDAMENTALS Programming languages have variables which
can contain values. Examples: var testString = “Testing”; var testNumber = 42; var testBoolean = true; -
Variables allow you to store data so that it can
be referred to later. -
LET’S SEE SOME EXAMPLES Head over to http://repl.it/ so we
can play around with some JavaScript -
This part of the presentation is being live coded with
the class. Sorry. -
MATH We’ll often need to perform mathematical operations in our
code. Basic math can be performed with different operators. Operators are characters that JavaScript recognizes as performing a certain function. -
Addition: + Subtraction: - Mutliplication: * Division: / Remainder Division
(Modulus): % Exponents: ^ Increment: ++ Decrement: - - ARITHMETIC OPERATORS -
LET’S DO SOME MATH Head back to http://repl.it/ so we
can perform some quick math -
This part of the presentation is being live coded with
the class. Sorry. -
ARRAYS Arrays are collections of data where each item in
the collection is assigned a numerical index. These indexes always start at 0. You can think of them like a list of items. To access a single item in the array you use the variable name of the array and the index of the item you want to access. -
var fruitArray = [ ‘banana’, //0 ‘apple’, //1 ‘orange’ //2
]; console.log(fruitArray[1]); //this will output “apple” -
var numberArray = [ 12345, //0 67890, //1 14323, //2
78519, //3 ]; console.log(numberArray[0]); //this will output 12345 -
IF STATEMENTS If statements are one of the basic building
blocks of programming logic. You tell the interpreter to execute the code inside the statement if a certain condition is met. -
Equality: === Inequality: !== Less Than: < Less Than or
Equal To: <= Greater Than: > Greater Than or Equal To: >= AND: && OR: || COMPARISON OPERATORS -
var fruit = “banana”; if(fruit === “apple”) { console.log(“Apples are
awesome.”); } else { console.log(“Boo! This is a “ + fruit + “.”); } -
LOOPS Loops allow you to iterate through an array or
to execute some code a specific number of times. We will be talking about the for loop and the while loop. -
FOR is great for iterating through arrays WHILE is great
for running code until a condition is met -
var fruitArray = [ ‘apple’, ‘banana’, ‘orange’ ]; for(var i
= 0; i < fruitArray.total; i++) { console.log(‘Current fruit: ‘ + fruitArray[i]); } -
var fruitArray = [ ‘apple’, ‘banana’, ‘orange’ ]; var notOrange
= true; var count = 0; while(notOrange) { if(fruitArray[count] === ‘orange’) { notOrange = false; } console.log(fruitArray[count] + “is not an orange.”); count++; } -
OBJECTS Objects are similar to arrays, but instead of numeric
indexes, the items in an object have names, these named values are called parameters Object parameters are accessed by using the name of the object a period and then the name of the parameter you would like to access. Objects can also store functions. -
var fruitObject = { type: “banana”, //fruitObject.type color: “yellow”, //fruitObject.color
price: 0.99 //fruitObject.price }; console.log(fruitObject.type); //this outputs “banana” -
FUNCTIONS Functions are reusable blocks of code that perform an
action. You can create a function out of any parts of your code. You call a function by using it’s name and then a set of parentheses ( ). -
function fruitFunction() { var fruitArray = [ ‘apple’, ‘banana’, ‘orange’
]; for(var i = 0; i < fruitArray.total; i++) { console.log(‘Current fruit: ‘ + fruitArray[i]); } } fruitFunction(); //this triggers our code above -
Let’s head over to http://codepen.io/ and start building our example.
We’ll be getting into simple jQuery selectors and some basic jQuery methods while we are coding. We could spend all day talking about jQuery so this will just be a quick introduction. -
This part of the presentation is being live coded with
the class. Sorry.