introduction to web frontend development with javascript

31
Introduction to Web Frontend Development with JavaScript

Upload: baakir

Post on 23-Feb-2016

65 views

Category:

Documents


0 download

DESCRIPTION

Introduction to Web Frontend Development with JavaScript. Network of Computer Networks. Internet. World Wide Web. The part of the Internet that communicates http and (often) html. HTTP. HyperText Transfer Protocol Client/Server Network Protocol - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Introduction  to  Web Frontend Development with JavaScript

Introduction to Web Frontend Development

with JavaScript

Page 2: Introduction  to  Web Frontend Development with JavaScript

InternetNetwork of Computer Networks

Page 3: Introduction  to  Web Frontend Development with JavaScript

World Wide WebThe part of the Internet that communicates http and (often) html.

Page 4: Introduction  to  Web Frontend Development with JavaScript

HTTP• HyperText Transfer Protocol• Client/Server Network Protocol• Requests are sent with Verbs to

Resources• Get, Post, Put, Delete, Patch, Trace, Options

• Responses are returned by the server with a status code• 200 OK, 404 Not Found, 301 Permanent

Redirect

Page 5: Introduction  to  Web Frontend Development with JavaScript

Web Developmentis hard. You must know at least 3 (often 4) programming languages:

JavaScript the state and behavior of then frontend

CSS how things look

HTML structure of the UI/Document

Server Programming Stateful storage and interaction with other servers

Page 6: Introduction  to  Web Frontend Development with JavaScript

But you can make great things!

Page 8: Introduction  to  Web Frontend Development with JavaScript

Not to mention all this stuff:

Page 9: Introduction  to  Web Frontend Development with JavaScript

Let’s start…

Page 10: Introduction  to  Web Frontend Development with JavaScript

Firefox ScratchpadShift+F4

Page 11: Introduction  to  Web Frontend Development with JavaScript

alert()Modal window

Page 12: Introduction  to  Web Frontend Development with JavaScript

prompt()Rarely used. Modal window.

Page 13: Introduction  to  Web Frontend Development with JavaScript

console.log()Shows in console

Page 15: Introduction  to  Web Frontend Development with JavaScript

varvar aNumber = 1, aString = "a string", anArray = [1, 2, "string"], anObject = {a: 1; b: "string", "c": 4};

Page 16: Introduction  to  Web Frontend Development with JavaScript

If Statementif ( /* something truthy */ ) { //code to execute}else { // code to execute}

Page 17: Introduction  to  Web Frontend Development with JavaScript

Switch Statementswitch (variable) { case value1: //statements break; case value2: //more statementsdefault: //more statements break;}

Page 18: Introduction  to  Web Frontend Development with JavaScript

for loopfor (var i = 0; i < 5; i++) { //statements}

Page 22: Introduction  to  Web Frontend Development with JavaScript

Weak Dynamic Typing

Page 23: Introduction  to  Web Frontend Development with JavaScript

TruthyWhen a value will be “true enough” for an if (or while) condition.

Page 24: Introduction  to  Web Frontend Development with JavaScript

Truthy vs true

var obj = {};console.log("an empty object is not equal to true: " + (obj == true));if (obj) { console.log("but it’s truthy");}

Page 25: Introduction  to  Web Frontend Development with JavaScript

Two Concepts1.A value that is not equal to true may still be truthy.

2.A value that is equal to true is truthy.

Page 26: Introduction  to  Web Frontend Development with JavaScript

Truthinesstrue1[1, 2]{a: 1}"something"

Page 27: Introduction  to  Web Frontend Development with JavaScript

Falsinessfalse0""NaNundefinednull

Page 28: Introduction  to  Web Frontend Development with JavaScript

Two comparison Operators

== (equal) vs. === (strictly equal)

Page 29: Introduction  to  Web Frontend Development with JavaScript

== does type coercion It checks whether the values can be coerced into the same type and then if their values become equal.

Page 30: Introduction  to  Web Frontend Development with JavaScript

=== checks type and valueALWAYS use ===

Page 31: Introduction  to  Web Frontend Development with JavaScript

== vs ===1 == 1

true1 == "1"

true1 == true

true0 == false

true

1 === 1true

1 === "1"false

1 === truefalse

0 === falsefalse