Frontend II: Javascript and DOM Programming. Wednesday, January 7, 15

Similar documents
Welcome to CS50 section! This is Week 10 :(

welcome to BOILERCAMP HOW TO WEB DEV

Midterm Exam. 5. What is the character - (minus) used for in JavaScript? Give as many answers as you can.

CS312: Programming Languages. Lecture 21: JavaScript

Why Discuss JavaScript? CS312: Programming Languages. Lecture 21: JavaScript. JavaScript Target. What s a Scripting Language?

JavaScript CS 4640 Programming Languages for Web Applications

Frontend guide. Everything you need to know about HTML, CSS, JavaScript and DOM. Dejan V Čančarević

BEFORE CLASS. If you haven t already installed the Firebug extension for Firefox, download it now from

JavaScript Lecture 1

JavaScript CS 4640 Programming Languages for Web Applications

JQuery and Javascript

JavaScript or: How I Learned to Stop Worrying and Love a Classless Loosely Typed Language

COURSE OUTLINE MOC 20480: PROGRAMMING IN HTML5 WITH JAVASCRIPT AND CSS3

Human-Computer Interaction Design

User Interaction: jquery

5. Strict mode use strict ; 6. Statement without semicolon, with semicolon 7. Keywords 8. Variables var keyword and global scope variable 9.

FALL 2017 CS 498RK JAVASCRIPT. Fashionable and Functional!

JavaScript or: HOW I LEARNED TO STOP WORRYING AND LOVE A CLASSLESS*

729G26 Interaction Programming. Lecture 4

Learn Web Development CodersTrust Polska course outline. Hello CodersTrust! Unit 1. HTML Structuring the Web Prerequisites Learning pathway.

CSC 337. jquery Rick Mercer

Client vs Server Scripting

D3js Tutorial. Tom Torsney-Weir Michael Trosin

JavaScript: the Big Picture

The course is supplemented by numerous hands-on labs that help attendees reinforce their theoretical knowledge of the learned material.

JavaScript. The Bad Parts. Patrick Behr

widgetjs Documentation

a Very Short Introduction to AngularJS

The Structure of the Web. Jim and Matthew

Outline. Introduction to JavaScript Resources What is JavaScript? JavaScript in web pages

TIME SCHEDULE MODULE TOPICS PERIODS. HTML Document Object Model (DOM) and javascript Object Notation (JSON)

JAVASCRIPT AND JQUERY: AN INTRODUCTION (WEB PROGRAMMING, X452.1)

INF5750. Introduction to JavaScript and Node.js

jquery with Fundamentals of JavaScript Training

JavaScript. History. Adding JavaScript to a page. CS144: Web Applications

WEB DEVELOPER BLUEPRINT

JavaScript, jquery & AJAX

React. HTML code is made up of tags. In the example below, <head> is an opening tag and </head> is the matching closing tag.

JavaScript. History. Adding JavaScript to a page. CS144: Web Applications

CISC 1600 Lecture 2.4 Introduction to JavaScript

JQuery WHY DIDN T WE LEARN THIS EARLIER??!

Client Side JavaScript and AJAX

Module 5 JavaScript, AJAX, and jquery. Module 5. Module 5 Contains an Individual and Group component

jquery Tutorial for Beginners: Nothing But the Goods

Unobtrusive JavaScript (Sample Chapter)

CGS 3066: Spring 2015 JavaScript Reference

ITS331 Information Technology I Laboratory

JAVASCRIPT AND JQUERY: AN INTRODUCTION (WEB PROGRAMMING, X452.1)

Session 3: JavaScript - Structured Programming

Lecture 8. ReactJS 1 / 24

UNIT -II. Language-History and Versions Introduction JavaScript in Perspective-

Information Design. Professor Danne Woo! infodesign.dannewoo.com! ARTS 269 Fall 2018 Friday 10:00PM 1:50PM I-Building 212

JavaScript Introduction

JavaScript for PHP Developers

THE HITCHHIKERS GUIDE TO. Harper Maddox CTO, EdgeTheory 30 September 2014

Introduction to JavaScript p. 1 JavaScript Myths p. 2 Versions of JavaScript p. 2 Client-Side JavaScript p. 3 JavaScript in Other Contexts p.

Module 5 JavaScript, AJAX, and jquery. Module 5. Module 5 Contains 2 components

FRONT END DEVELOPER CAREER BLUEPRINT

JavaScript and the DOM MIS Konstantin Bauman. Department of MIS Fox School of Business Temple University

CS197WP. Intro to Web Programming. Nicolas Scarrci - February 13, 2017

WELCOME TO JQUERY PROGRAMMING LANGUAGE ONLINE TUTORIAL

Boot Camp JavaScript Sioux, March 31, 2011

Web Programming and Design. MPT Junior Cycle Tutor: Tamara Demonstrators: Aaron, Marion, Hugh

Tizen Web UI Technologies (Tizen Ver. 2.3)

Introduction to Web Development

this is a cat CS50 Quiz 1 Review

RequireJS Javascript Modules for the Browser. By Ben Keith Quoin, Inc.

Web Application Development

django-dajax Documentation

Multimedia im Netz Online Multimedia Winter semester 2015/16

Design patterns and Animation with jquery. with Paul Bakaus

Node.js Training JavaScript. Richard richardrodger.com

IN Development in Platform Ecosystems Lecture 2: HTML, CSS, JavaScript

Chapter 9 Introducing JQuery

COURSE 20480B: PROGRAMMING IN HTML5 WITH JAVASCRIPT AND CSS3

Dynamic Dates with CSS Sprites+

1 Introduction. 2 Web Architecture

Alert. In [ ]: %%javascript alert("hello");

JAVASCRIPT. The Basics

Programming in HTML5 with JavaScript and CSS3

Apps Framework API. Version Samsung Smart Electronics Copyright All Rights Reserved

The DOM and jquery functions and selectors. Lesson 3

Brief Intro to Firebug Sukwon Oh CSC309, Summer 2015

UI Course HTML: (Html, CSS, JavaScript, JQuery, Bootstrap, AngularJS) Introduction. The World Wide Web (WWW) and history of HTML

CSE 154: Web Programming Autumn 2018

Modern JavaScript. Keith Donald - SpringSource SpringOne 2GX All rights reserved. Do not distribute without permission.

Web Development 20480: Programming in HTML5 with JavaScript and CSS3. Upcoming Dates. Course Description. Course Outline

JavaScript: the language of browser interactions. Claudia Hauff TI1506: Web and Database Technology

INTRODUCTION TO JAVASCRIPT

HTML 5 and CSS 3, Illustrated Complete. Unit L: Programming Web Pages with JavaScript

JavaScript Rd2. -Kyle Simpson, You Don t Know JS

Comp 426 Midterm Fall 2013

IAT 355 : Lab 01. Web Basics

Background. Javascript is not related to Java in anyway other than trying to get some free publicity

SEEM4570 System Design and Implementation Lecture 03 JavaScript

Intro To Javascript. Intro to Web Development

Copyright Descriptor Systems, Course materials may not be reproduced in whole or in part without prior written consent of Joel Barnum

Sample CS 142 Midterm Examination

JQUERYUI - TOOLTIP. content This option represents content of a tooltip. By default its value is function returning the title attribute.

JQUERYUI - PROGRESSBAR

Transcription:

6.148 Frontend II: Javascript and DOM Programming

Let s talk about Javascript :)

Why Javascript? Designed in ten days in December 1995!

How are they similar?

Javascript is to Java as hamster is to ham

Marketing! Java began to become immensely popular in the 90s as a powerful programming language

Marketing! Java began to become immensely popular in the 90s as a powerful programming language Javascript -- influenced more by Scheme than Java! Scheme, with syntax borrowed from C

wat

... we have to appreciate the reasons for picking not the most powerful solution but the least powerful -- Tim Berners-Lee, 1998

... we have to appreciate the reasons for picking not the most powerful solution but the least powerful -- Tim Berners-Lee, 1998 Any application that can be written in Javascript, will eventually be written in Javascript -- Atwood s Corollary, 2007

Javascript: The Good Parts Javascript: The Definitive Guide

So why are we learning a language that... was built in 10 days... can t decide if it s functional or object-oriented... has become the butt of computer-science jokes everywhere???

Let s get real Objectively, Javascript isn t that bad In fact, many of us who have gotten to know it enjoy it A language with a good, small core, and lots of unnecessary fluff Learn to use the good parts

A new hope...for JS Better standards: ECMAScript Google V8 Javascript on the client and server! Tons of libraries -- Javascript is (re)gaining popularity!

A lightning overview var n = 3; var str = hello! if (n == 3) { console.log( three ); } else { console.log( not three ); } for (var i = 0; i < 10; i++) { console.log(3 * i); }

Arrays var a = [1, 2, 3]; var b = []; for (var i = 0; i < a.length; i++) { b.push(2*a); } console.log(b) // [2, 4, 6]

Objects var obj = { 1: hi, 2: 3, abc : def, array : [1,2,3,4,5] }; console.log(obj[1]); console.log(obj.abc); console.log(obj.hello); // hi // def // undefined

Functions! function f(a, b) { return a + b; } var f = function(a, b) { return a + b; }

Functions! function f(a, b) { return a + b; } var f = function(a, b) { return a + b; } A function can be treated just like any other variable!

Candy var func = function(f) { } return f(3); What is func(function(x) { return x; });

Candy var func = function(f) { return f(3); } var a = function(x) { return 2 * x; } What is func(a);

Candy var func = function(f) { } return f; What is func(function(x) { return x; });

Candy var func = function(f) { } return f; What is func(function(x) { return x; })(3);

Candy var func = function() { return [1,2,3] }; What is func();

Use your semicolons

More candy! What is... 20 == 20

More candy! What is... 20 == 20 // TRUE false == 0

More candy! What is... 20 == 20 // TRUE false == 0 // TRUE [] == []

More candy! What is... 20 == 20 // TRUE false == 0 // TRUE [] == [] // FALSE == 0

More candy! What is... 20 == 20 // TRUE false == 0 // TRUE [] == [] // FALSE == 0 // TRUE \n\n\n == 0

More candy! What is... 20 == 20 // TRUE false == 0 // TRUE [] == [] // FALSE == 0 // TRUE \n\n\n == 0 // TRUE NaN == NaN

More candy! What is... 20 == 20 // TRUE false == 0 // TRUE [] == [] // FALSE == 0 // TRUE \n\n\n == 0 NaN == NaN // TRUE // FALSE

Use === and!==

Javascript for the Browser HTML: gives us a nested tree structure of elements Manipulate these elements with Javascript! The DOM DEMO

jquery Writing Javascript for the browser is cumbersome! jquery allows us to write less by using CSS selectors and providing helper functions $( div ) $(.classname ) $( #element- id ) DEMO

What can we do with jquery? Find an element -- $( #element- id ) DOM tree traversal Element styles: show, hide, add/remove classes, change CSS Add and remove DOM elements and HTML!

Events! $( #element- id ).on( click, function(event) {... } ); Events: hover, mousedown, mouseup, keypress, etc... Shortcuts:.click(...),.hover(...), etc.

Events! $( #element- id ).on( click, function(event) {... } ); Events: hover, mousedown, mouseup, keypress, etc... Shortcuts:.click(...),.hover(...), etc. REMEMBER: functions are just like any other variable!

Callbacks?!? Javascript is asynchronous For now, just think of it as -- not everything executes in the order written

Callbacks?!? Javascript is asynchronous For now, just think of it as -- not everything executes in the order written $( #element- id ).on( click, function(event) {... } );

Callbacks?!? $( #element- id ).on( click, function(event) {... } ); Hey browser, call this function whenever someone clicks on #element-id The callback function is executed only when the event triggers it

DEMO Making a list