IDM 231. Functions, Objects and Methods

Size: px
Start display at page:

Download "IDM 231. Functions, Objects and Methods"

Transcription

1 IDM 231 Functions, Objects and Methods IDM 231: Scripting for IDM I 1 Browsers require very detailed instructions about what we want them to do. Therefore, complex scripts can run to hundreds (even thousands) of lines. Programmers use functions, methods, and objects to organize their code. Functions consist of a series of statements that have been grouped together because they perform a specific task. A method is the same as a function, except methods are created inside an object. Objects are made of up properties and methods. We'll look at all of these in more detail.

2 Functions function updatemessage() { var el = document.getelementbyid('message'); el.textcontent = msg; return msg; } updatemessage(); IDM 231: Scripting for IDM I 2 Functions let you group a series of statements together to perform a specific task. If different parts of a script repeat the same task, you can reuse the function rather than repeating the same set of statements. When you group tasks together into a function, you need to give your function a name, which should describe the task it is performing. When you ask it to perform the task it's known as calling the function.

3 Function Structure function updatemessage() { var el = document.getelementbyid('message'); el.textcontent = msg; return msg; } updatemessage(); IDM 231: Scripting for IDM I 3 The steps the function needs to perform in are packaged up in a code block. A code block consists of one ore more statements contained within curly braces.

4 Function Parameters function updatemessage(name, message) { console.log('hello ' + name + ', ' + message); // or with ES6 console.log(`hello ${name}, ${message}`); } updatemessage(); IDM 231: Scripting for IDM I 4 Some functions need to be provided with information in order to achieve a given task. Pieces of information passed to a function are known as parameters.

5 Working With Parameters function getarea(width, height) { return width * height; } getarea(3, 5); var wall_width = 3; var wall_height = 5; getarea(wall_width, wall_height); IDM 231: Scripting for IDM I 5 Inside the function, the parameters act like variables.

6 Function Return function updatemessage(name, message) { const newmessage = `Hello ${name}, ${message}`; return newmessage; } let mymessage = updatemessage('phil', 'Welcome to my script!'); console.log(mymessage); // Hello Phil, Welcome to my script! IDM 231: Scripting for IDM I 6 When you write a function and you expect it to provide you with an answer, the response is known as a return value. Using the return keyword, the specified value is returned from inside the function, back to the placeholder that originally called the function. When a return statement is encountered, the execution of the function immediately stops and the current value of the returned variable is extracted. If the function contains more lines of code, they are not executed.

7 Anatomy of a Function function sayhello() { console.log('hello!'); } IDM 231: Scripting for IDM I 7 Let's review. You declare a function using the function keyword. You give the function a name (sometimes called an identifier) followed by parentheses. The statements that perform the task sit in a code block, inside the curly braces.

8 Calling a Function function sayhello() { console.log('hello!'); } sayhello(); IDM 231: Scripting for IDM I 8 Once you declare a function, you can execute all the statements between the curly braces with a single line of code. This is know as calling the function. This is done by using the function name followed by parentheses. You can call the same function as many times as you want within the same Javascript file.

9 Getting Values Out of a Function function getarea(width, height) { const area = width * height; return area; } let wall = getarea(3, 5); // 15 let wall = getarea(8, 5); // 40 IDM 231: Scripting for IDM I 9 Some functions return information to the code that called them. wall1 will be equal to 15, while wall2 will hold the value 40. This also demonstrates how the same function can be used to perform the same steps with different values.

10 Getting Multiple Values Out of a Function function getsize(width, height, depth) { const area = width * height; const volume = width * height * depth; } // Does this work? // Why or why not? return area; return volume; let sizes = getsize(3,2,3); IDM 231: Scripting for IDM I 10 Someone tell me, how could we get more than one value out of a function?

11 Return Arrays function getsize(width, height, depth) { const area = width * height; const volume = width * height * depth; const sizes = [area, volume]; return sizes; } let area_one = getsize(3,2,3)[0]; let volume_one = getsize(3,2,3)[1]; IDM 231: Scripting for IDM I 11 Functions can return more than one value using an array.

12 Arrow Functions const myfunction = function() { //... } const myfunction = () => { //... } IDM 231: Scripting for IDM I 12 ES6 introduced a new syntax for the anatomy of a function, the arrow function. Visually, the arrow function simplifies the syntax, making it shorter, which is a welcome change.

13 Arrow Functions - Single Statement const myfunction = function() { dosomething(); } // Becomes const myfunction = () => dosomething(); IDM 231: Scripting for IDM I 13 If the function of the body contains a single statement, you can omit the brackets and write it all on a single line.

14 Arrow Function - Parameters const myfunction = function(param1, param2) { dosomething(param1, param2); }; // Becomes const myfunction = (param1, param2) => dosomthing(param1, param2); IDM 231: Scripting for IDM I 14 Parameters are passing in the parentheses.

15 Arrow Functions - Single Parameter const myfunction = param => dosomething(param); IDM 231: Scripting for IDM I 15 If you have one (and only one) parameter, you can omit the parentheses completely. Because of the short syntax, arrow functions encourage the use of small functions, which is one of our goals when writing clean, concise scripts.

16 Variable Scope Local vs Global vs Block IDM 231: Scripting for IDM I 16 The location where you declare a variable will affect where it can be used within your code. If you declare it within a function, it can only be used within that function This is known as the variable's scope.

17 Local Scope function getarea(width, height) { var area = width * height; return area; } console.log(area); // ERROR IDM 231: Scripting for IDM I 17 When a variable is created inside a function using the var keyword, it can only be used in that function. It is called a local variable or function-level variable. It is said to have local scope or function-level scope. It cannot be accessed outside of the function in which it was declared. In this example, area is a local variable, only available within the getarea function. area is only available within the getarea() function. Trying to access it outside of that function will produce an error.

18 Global Scope function getarea(width, height) { var area = width * height; return area; } var wallsize = getarea(3,2); console.log(wallsize); // 6 wallsize = 'dog'; console.log(wallsize); // dog IDM 231: Scripting for IDM I 18 If you create a variable outside of a function, then it can be used anywhere within the script. It is called a global variable and has global scope. Global variables are stored in memory for as long as the web page is loaded in the browser, which means they take up more memory than local variables.

19 var Does Not Have Block Scope var x = 1; function myfunction() { x = 2; } console.log(x); // 2 IDM 231: Scripting for IDM I 19 Variables declared with the var keyword do not have block scope, which means if a variable is introduced within a code block, those variables are scoped to the containing function, and the effects of setting them persist beyond the block itself.

20 let & const Do Have Block Scope let x = 1; function myfunction() { let x = 2; console.log(x); // 2 } console.log(x); // 1 IDM 231: Scripting for IDM I 20 By contrast, variables declared with let and const do have block scope. The x = 2 is limited in scope to the block in which it was defined. (This example is using let, but the rules are the same for const)

21 Variable Scope Examples IDM 231: Scripting for IDM I 21 examples/functions/scope.js

22 Objects object variable is called a property functions are called methods IDM 231: Scripting for IDM I 22 Objects group together a set of variables and functions to create a model of something you would recognize from the real world. In an object, variables and functions take on new names. (click) If a variable is part of an object, it is called a property. (click) If a function is part of an object, it is called a method. Methods represent tasks that are associated with the object.

23 Object Example const hotel = { name: 'Hurley\'s Inn', rooms: 40, booked: 25, gym: true, roomtypes: ['twin', 'double', 'suite'], checkavailability: function() { return this.rooms - this.booked; } }; IDM 231: Scripting for IDM I 23 Like variables and named functions, properties and methods have a name and a value. In an object, that name is called a key (the keys in this example would be name, rooms etc). The value of a property can be a string, number, boolean, array, or even another object. The value of a method is always a function (checkavailability). The object is the curly braces and their contents. In this example, the object is stored in a variable called hotel, so you would refer to it as the hotel object. Separate each key from its value using a colon. Separate each property and method with a comma, except the last value.

24 Accessing Properties & Methods const hotelname = hotel.name; const roomsfree = hotel.checkavailability(); IDM 231: Scripting for IDM I 24 You access the properties and methods of an object using what's called dot notation. Use the name of the object, followed by a period, then the name of the property or method you want to access.

25 Accessing Properties & Methods (bracket syntax) const hotelname = hotel['name']; IDM 231: Scripting for IDM I 25 You can also access the properties of an object (but not its methods) using square bracket syntax. This syntax should generally be avoided.

26 Updating an Object hotel.name = 'Aztec'; delete hotel.name; IDM 231: Scripting for IDM I 26 To update a property, use the same technique for assigning a variable value, first naming the object name, then the property, followed by the equals sign, and then the new value. To delete a property, use the delete keyword followed by the object name and property name.

27 Creating Many Objects function Hotel(name, rooms, booked) { this.name = name; this.rooms = rooms; this.booked = booked; this.checkavailability = function() { return this.rooms - this.booked; }; } IDM 231: Scripting for IDM I 27 Sometimes you want several objects to represent similar things. Object constructors can use a function as a template for create objects. First you create the template with the object's properties and methods. The this keyword is used instead of the object name to indicate that the property or method belongs to the object that this function creates.

28 Creating More Objects const hurleyhotel = new Hotel('Hurley\'s', 40, 25); const aztechotel = new Hotel('Aztec', 120, 77); IDM 231: Scripting for IDM I 28 You create instances of the object using the construction function. The new keyword followed by a call to the function creates a new object. The properties of each object are given as arguments to the function.

29 Objects Example IDM 231: Scripting for IDM I 29 examples/objects/objects.js

30 Built-In Objects IDM 231: Scripting for IDM I 30 Browsers come with a set of built-in objects that represent things like the browser window and the current web page shown in that window. These built-in objects act like a toolkit for creating interactive web pages. As soon as a web page has loaded into the browser, these objects are available to use in your scripts. These built-in objects help you get a wide range of information such as the width of the browser window, the content of the main heading in the page, or the length of text a user entered into a form field. You access their properties or methods using dot notation, just like you would access the properties or methods of an object you had written yourself.

31 Three Groups of Built-In Objects 1. window object 2. document object 3. global objects IDM 231: Scripting for IDM I 31 The three sets of built-in objects each offer different range of tools that help you write scripts for web pages.

32 window Object Properties window.innerheight window.innerwidth window.pagexoffset window.pageyoffset window.screenx window.screeny window.location IDM 231: Scripting for IDM I 32 The window object represents the current browser window or tab. It is the topmost object in the Browser Object Model, and it contains other objects that tell you about the browser. Here are a selection of some the window object's properties. Height/width of window (excluding browser chrome/ UI) in pixels. Distance document has been scrolled in pixels. X/Y coordinate of pointer Current URL of window object (local file path)

33 window Object Methods window.alert(); window.open(); window.print(); IDM 231: Scripting for IDM I 33 Here are a selection of some the window object's properties and methods. Alert creates a dialog box, open opens a new window, print tells the browser that the user wants to print the contents of the page. examples/objects/objects_window.html

34 document Object Properties document.title document.lastmodified document.url document.domain IDM 231: Scripting for IDM I 34 The topmost object in the Document Object Model (or DOM) is the document object. It represents the web page loaded into the current browser window or tab. Here are some properties of the document object, which tell you about the current page. Title of current document Date on which document was last modified Returns string containing URL of current document Returns domain of current document

35 document Object Methods document.write() document.getelementbyld() document.queryselector() document.queryselectorall() document.createelement() document.createtextnode() IDM 231: Scripting for IDM I 35 The DOM is vital to accessing and amending the contents of the current web page. The following are a few of the methods that select content or update the content of a page. Writes text to document Returns element, if there is an element with the value of the id attribute that matches Returns the first instance of an element that match a CSS selector, which is specified as a parameter Returns list of elements that match a CSS selector, which is specified as a parameter Creates new element Creates new text node examples/objects/objects_document.html js

36 Global Objects: String Object Properties length IDM 231: Scripting for IDM I 36 Whenever you have a value that is a string, you can use the properties and methods of the String object on that value. The length property counts the number of "code units" in a string. In the majority of cases, one character uses one code unit, and most programmers use it like this. But some of the rarely used characters take up two code units.

37 Changes string to uppercase characters Changes string to lowercase characters Takes an index number as a parameter, and returns the character found at that position Returns index number of the first time a character or set of characters is found within the string Returns index number of the last time a character or set of characters is found within the string Returns characters found between two index numbers where the character for the first index number is included and the character for the last index number is not included When a character is specified, it splits the string each time it is found, then stores each individual part in an array Removes whitespace from start and end of string Like find and replace, it takes one value that should be found, and another to replace it (by default, it only replaces the first match it finds) examples/objects/objects_string.js Global Objects: String Object Methods touppercase() tolowercase() charat() indexof() lastlndexof() substring() split() trim() replace() IDM 231: Scripting for IDM I 37

38 For next week IDM 231: Scripting for IDM I 38

JavaScript and Objects CS 4640 Programming Languages for Web Applications

JavaScript and Objects CS 4640 Programming Languages for Web Applications JavaScript and Objects CS 4640 Programming Languages for Web Applications 1 Objects How group do variables Web and Apps functions fit to create in with a model the World Around Them? representing something

More information

JavaScript: Objects, BOM, and DOM CS 4640 Programming Languages for Web Applications

JavaScript: Objects, BOM, and DOM CS 4640 Programming Languages for Web Applications JavaScript: Objects, BOM, and DOM CS 4640 Programming Languages for Web Applications 1 Objects How group do variables Web and Apps functions fit to create in with a model the World Around Them? representing

More information

Manju Muralidharan Priya. CS4PM Web Aesthetics and Development WEEK 11

Manju Muralidharan Priya. CS4PM Web Aesthetics and Development WEEK 11 CS4PM Web Aesthetics and Development WEEK 11 Objective: Understand basics of JScript Outline: a. Basics of JScript Reading: Refer to w3schools websites and use the TRY IT YOURSELF editor and play with

More information

Place User-Defined Functions in the HEAD Section

Place User-Defined Functions in the HEAD Section JavaScript Functions Notes (Modified from: w3schools.com) A function is a block of code that will be executed when "someone" calls it. In JavaScript, we can define our own functions, called user-defined

More information

Lecture 05 I/O statements Printf, Scanf Simple statements, Compound statements

Lecture 05 I/O statements Printf, Scanf Simple statements, Compound statements Programming, Data Structures and Algorithms Prof. Shankar Balachandran Department of Computer Science and Engineering Indian Institute of Technology, Madras Lecture 05 I/O statements Printf, Scanf Simple

More information

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

Information Design. Professor Danne Woo! infodesign.dannewoo.com! ARTS 269 Fall 2018 Friday 10:00PM 1:50PM I-Building 212 Information Design Professor Danne Woo! infodesign.dannewoo.com! ARTS 269 Fall 2018 Friday 10:00PM 1:50PM I-Building 212 Interactive Data Viz Week 8: Data, the Web and Datavisual! Week 9: JavaScript and

More information

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

5. Strict mode use strict ; 6. Statement without semicolon, with semicolon 7. Keywords 8. Variables var keyword and global scope variable 9. Javascript 1) Javascript Implementation 1. The Core(ECMAScript) 2. DOM 3. BOM 2) ECMAScript describes 1. Syntax 2. Types 3. Statements 4. Keywords 5. Reserved words 6. Operators 7. Objects 3) DOM 1. Tree

More information

PES DEGREE COLLEGE BANGALORE SOUTH CAMPUS 1 K.M. before Electronic City, Bangalore WEB PROGRAMMING Solution Set II

PES DEGREE COLLEGE BANGALORE SOUTH CAMPUS 1 K.M. before Electronic City, Bangalore WEB PROGRAMMING Solution Set II PES DEGREE COLLEGE BANGALORE SOUTH CAMPUS 1 K.M. before Electronic City, Bangalore 560 100 WEB PROGRAMMING Solution Set II Section A 1. This function evaluates a string as javascript statement or expression

More information

CS1046 Lab 4. Timing: This lab should take you 85 to 130 minutes. Objectives: By the end of this lab you should be able to:

CS1046 Lab 4. Timing: This lab should take you 85 to 130 minutes. Objectives: By the end of this lab you should be able to: CS1046 Lab 4 Timing: This lab should take you 85 to 130 minutes. Objectives: By the end of this lab you should be able to: Define the terms: function, calling and user-defined function and predefined function

More information

Code Editor. The Code Editor is made up of the following areas: Toolbar. Editable Area Output Panel Status Bar Outline. Toolbar

Code Editor. The Code Editor is made up of the following areas: Toolbar. Editable Area Output Panel Status Bar Outline. Toolbar Code Editor Wakanda s Code Editor is a powerful editor where you can write your JavaScript code for events and functions in datastore classes, attributes, Pages, widgets, and much more. Besides JavaScript,

More information

The first sample. What is JavaScript?

The first sample. What is JavaScript? Java Script Introduction JavaScript is the most popular scripting language on the internet, and works in all major browsers, such as Internet Explorer, Firefox, Chrome, Opera, and Safari. In this lecture

More information

JavaScript CS 4640 Programming Languages for Web Applications

JavaScript CS 4640 Programming Languages for Web Applications JavaScript CS 4640 Programming Languages for Web Applications 1 How HTML, CSS, and JS Fit Together {css} javascript() Content layer The HTML gives the page structure and adds semantics Presentation

More information

1. Cascading Style Sheet and JavaScript

1. Cascading Style Sheet and JavaScript 1. Cascading Style Sheet and JavaScript Cascading Style Sheet or CSS allows you to specify styles for visual element of the website. Styles specify the appearance of particular page element on the screen.

More information

Quiz 1: Functions and Procedures

Quiz 1: Functions and Procedures Quiz 1: Functions and Procedures Outline Basics Control Flow While Loops Expressions and Statements Functions Primitive Data Types 3 simple data types: number, string, boolean Numbers store numerical data

More information

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

JavaScript: the language of browser interactions. Claudia Hauff TI1506: Web and Database Technology JavaScript: the language of browser interactions Claudia Hauff TI1506: Web and Database Technology ti1506-ewi@tudelft.nl Densest Web lecture of this course. Coding takes time. Be friendly with Codecademy

More information

c122mar413.notebook March 06, 2013

c122mar413.notebook March 06, 2013 These are the programs I am going to cover today. 1 2 Javascript is embedded in HTML. The document.write() will write the literal Hello World! to the web page document. Then the alert() puts out a pop

More information

JavaScript Basics. The Big Picture

JavaScript Basics. The Big Picture JavaScript Basics At this point, you should have reached a certain comfort level with typing and running JavaScript code assuming, of course, that someone has already written it for you This handout aims

More information

COMS 469: Interactive Media II

COMS 469: Interactive Media II COMS 469: Interactive Media II Agenda Review Ch. 5: JavaScript An Object-Based Language Ch. 6: Programming the Browser Review Data Types & Variables Data Types Numeric String Boolean Variables Declaring

More information

PHP by Pearson Education, Inc. All Rights Reserved.

PHP by Pearson Education, Inc. All Rights Reserved. PHP 1992-2012 by Pearson Education, Inc. All Client-side Languages User-agent (web browser) requests a web page JavaScript is executed on PC http request Can affect the Browser and the page itself http

More information

EXERCISE: Introduction to client side JavaScript

EXERCISE: Introduction to client side JavaScript EXERCISE: Introduction to client side JavaScript Barend Köbben Version 1.3 March 23, 2015 Contents 1 Dynamic HTML and scripting 3 2 The scripting language JavaScript 3 3 Using Javascript in a web page

More information

JavaScript Functions, Objects and Array

JavaScript Functions, Objects and Array JavaScript Functions, Objects and Array Defining a Function A definition starts with the word function. A name follows that must start with a letter or underscore, followed by any number of letters, digits,

More information

Lesson 1: Writing Your First JavaScript

Lesson 1: Writing Your First JavaScript JavaScript 101 1-1 Lesson 1: Writing Your First JavaScript OBJECTIVES: In this lesson you will be taught how to Use the tag Insert JavaScript code in a Web page Hide your JavaScript

More information

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

Midterm Exam. 5. What is the character - (minus) used for in JavaScript? Give as many answers as you can. First Name Last Name CSCi 90.3 March 23, 2010 Midterm Exam Instructions: For multiple choice questions, circle the letter of the one best choice unless the question explicitly states that it might have

More information

Working with JavaScript

Working with JavaScript Working with JavaScript Creating a Programmable Web Page for North Pole Novelties 1 Objectives Introducing JavaScript Inserting JavaScript into a Web Page File Writing Output to the Web Page 2 Objectives

More information

Princess Nourah bint Abdulrahman University. Computer Sciences Department

Princess Nourah bint Abdulrahman University. Computer Sciences Department Princess Nourah bint Abdulrahman University 1 And use http://www.w3schools.com/ JavaScript Objectives Introduction to JavaScript Objects Data Variables Operators Types Functions Events 4 Why Study JavaScript?

More information

Section 1. How to use Brackets to develop JavaScript applications

Section 1. How to use Brackets to develop JavaScript applications Section 1 How to use Brackets to develop JavaScript applications This document is a free download from Murach books. It is especially designed for people who are using Murach s JavaScript and jquery, because

More information

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

BEFORE CLASS. If you haven t already installed the Firebug extension for Firefox, download it now from BEFORE CLASS If you haven t already installed the Firebug extension for Firefox, download it now from http://getfirebug.com. If you don t already have the Firebug extension for Firefox, Safari, or Google

More information

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

JavaScript. History. Adding JavaScript to a page. CS144: Web Applications JavaScript Started as a simple script in a Web page that is interpreted and run by the browser Supported by most modern browsers Allows dynamic update of a web page More generally, allows running an arbitrary

More information

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

JavaScript. History. Adding JavaScript to a page. CS144: Web Applications JavaScript Started as a simple script in a Web page that is interpreted and run by the browser Supported by most modern browsers Allows dynamic update of a web page More generally, allows running an arbitrary

More information

Exercise 1 Using Boolean variables, incorporating JavaScript code into your HTML webpage and using the document object

Exercise 1 Using Boolean variables, incorporating JavaScript code into your HTML webpage and using the document object CS1046 Lab 5 Timing: This lab should take you approximately 2 hours. Objectives: By the end of this lab you should be able to: Recognize a Boolean variable and identify the two values it can take Calculate

More information

JavaScript CS 4640 Programming Languages for Web Applications

JavaScript CS 4640 Programming Languages for Web Applications JavaScript CS 4640 Programming Languages for Web Applications 1 How HTML, CSS, and JS Fit Together {css} javascript() Content layer The HTML gives the page structure and adds semantics Presentation

More information

Chapter 2 Author Notes

Chapter 2 Author Notes Chapter 2 Author Notes Good Programming Practice 2.1 Every program should begin with a comment that explains the purpose of the program, the author and the date and time the program was last modified.

More information

IT441. Subroutines. (a.k.a., Functions, Methods, etc.) DRAFT. Network Services Administration

IT441. Subroutines. (a.k.a., Functions, Methods, etc.) DRAFT. Network Services Administration IT441 Network Services Administration Subroutines DRAFT (a.k.a., Functions, Methods, etc.) Organizing Code We have recently discussed the topic of organizing data (i.e., arrays and hashes) in order to

More information

JAVASCRIPT BASICS. JavaScript String Functions. Here is the basic condition you have to follow. If you start a string with

JAVASCRIPT BASICS. JavaScript String Functions. Here is the basic condition you have to follow. If you start a string with JavaScript String Functions Description String constants can be specified by enclosing characters or strings within double quotes, e.g. "WikiTechy is the best site to learn JavaScript". A string constant

More information

JavaScript for WordPress. Zac https://javascriptforwp.com/wcsea

JavaScript for WordPress. Zac https://javascriptforwp.com/wcsea JavaScript for WordPress Zac Gordon @zgordon https://javascriptforwp.com/wcsea Go Here to Get Setup javascriptforwp.com/wcsea Are We Ready?! 1. Slides and Example Files 2. Code Editor (I'm using Atom)

More information

Web Site Design and Development JavaScript

Web Site Design and Development JavaScript Web Site Design and Development JavaScript CS 0134 Fall 2018 Tues and Thurs 1:00 2:15PM JavaScript JavaScript is a programming language that was designed to run in your web browser. 2 Some Definitions

More information

JQuery and Javascript

JQuery and Javascript JQuery and Javascript Javascript - a programming language to perform calculations/ manipulate HTML and CSS/ make a web page interactive JQuery - a javascript framework to help manipulate HTML and CSS JQuery

More information

Functions Structure and Parameters behind the scenes with diagrams!

Functions Structure and Parameters behind the scenes with diagrams! Functions Structure and Parameters behind the scenes with diagrams! Congratulations! You're now in week 2, diving deeper into programming and its essential components. In this case, we will talk about

More information

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 8: SEP. 29TH INSTRUCTOR: JIAYIN WANG

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 8: SEP. 29TH INSTRUCTOR: JIAYIN WANG CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 8: SEP. 29TH INSTRUCTOR: JIAYIN WANG 1 Notice Prepare the Weekly Quiz The weekly quiz is for the knowledge we learned in the previous week (both the

More information

A pixel is not a pixel. Peter-Paul Koch SF HTML5, 6 April 2012

A pixel is not a pixel. Peter-Paul Koch   SF HTML5, 6 April 2012 A pixel is not a pixel Peter-Paul Koch http://quirksmode.org http://twitter.com/ppk SF HTML5, 6 April 2012 Example site http://mobilism.nl/2012/ A proper responsive site that you can use on any device

More information

Chapter 2, Part I Introduction to C Programming

Chapter 2, Part I Introduction to C Programming Chapter 2, Part I Introduction to C Programming C How to Program, 8/e, GE 2016 Pearson Education, Ltd. All rights reserved. 1 2016 Pearson Education, Ltd. All rights reserved. 2 2016 Pearson Education,

More information

The PCAT Programming Language Reference Manual

The PCAT Programming Language Reference Manual The PCAT Programming Language Reference Manual Andrew Tolmach and Jingke Li Dept. of Computer Science Portland State University September 27, 1995 (revised October 15, 2002) 1 Introduction The PCAT language

More information

Student, Perfect Final Exam May 25, 2006 ID: Exam No CS-081/Vickery Page 1 of 6

Student, Perfect Final Exam May 25, 2006 ID: Exam No CS-081/Vickery Page 1 of 6 Student, Perfect Final Exam May 25, 2006 ID: 9999. Exam No. 3193 CS-081/Vickery Page 1 of 6 NOTE: It is my policy to give a failing grade in the course to any student who either gives or receives aid on

More information

Chapter 17. Fundamental Concepts Expressed in JavaScript

Chapter 17. Fundamental Concepts Expressed in JavaScript Chapter 17 Fundamental Concepts Expressed in JavaScript Learning Objectives Tell the difference between name, value, and variable List three basic data types and the rules for specifying them in a program

More information

Week 3 Overview Week 2 review Operators Arithmetic Relational Logical 3 Outcomes Week 3 Overview Describe the advantages and techniques of modularized

Week 3 Overview Week 2 review Operators Arithmetic Relational Logical 3 Outcomes Week 3 Overview Describe the advantages and techniques of modularized ITEC 136 Business Programming Concepts Week 03, Part 01 Overview 1 Week 3 Overview Week 2 review Software Lifecycle Waterfall model Spiral model Variables Name (identifier) Data type Value Scope 2 Week

More information

UNIT 3 SECTION 1 Answer the following questions Q.1: What is an editor? editor editor Q.2: What do you understand by a web browser?

UNIT 3 SECTION 1 Answer the following questions Q.1: What is an editor? editor editor Q.2: What do you understand by a web browser? UNIT 3 SECTION 1 Answer the following questions Q.1: What is an editor? A 1: A text editor is a program that helps you write plain text (without any formatting) and save it to a file. A good example is

More information

(Refer Slide Time: 01:40)

(Refer Slide Time: 01:40) Internet Technology Prof. Indranil Sengupta Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Lecture No #25 Javascript Part I Today will be talking about a language

More information

Lesson: Web Programming(6) Omid Jafarinezhad Sharif University of Technology

Lesson: Web Programming(6) Omid Jafarinezhad Sharif University of Technology Lesson: Web Programming(6) Omid Jafarinezhad Sharif University of Technology React QUICK START QUICK START ADVANCED GUIDES React QUICK START Installation Hello World Introducing JSX Components and Props

More information

COMS 469: Interactive Media II

COMS 469: Interactive Media II COMS 469: Interactive Media II Agenda Review Data Types & Variables Decisions, Loops, and Functions Review gunkelweb.com/coms469 Review Basic Terminology Computer Languages Interpreted vs. Compiled Client

More information

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

Background. Javascript is not related to Java in anyway other than trying to get some free publicity JavaScript I Introduction JavaScript traditionally runs in an interpreter that is part of a browsers Often called a JavaScript engine Was originally designed to add interactive elements to HTML pages First

More information

Programming in ROBOTC ROBOTC Rules

Programming in ROBOTC ROBOTC Rules Programming in ROBOTC ROBOTC Rules In this lesson, you will learn the basic rules for writing ROBOTC programs. ROBOTC is a text-based programming language Commands to the robot are first written as text

More information

3 The Building Blocks: Data Types, Literals, and Variables

3 The Building Blocks: Data Types, Literals, and Variables chapter 3 The Building Blocks: Data Types, Literals, and Variables 3.1 Data Types A program can do many things, including calculations, sorting names, preparing phone lists, displaying images, validating

More information

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

HTML 5 and CSS 3, Illustrated Complete. Unit L: Programming Web Pages with JavaScript HTML 5 and CSS 3, Illustrated Complete Unit L: Programming Web Pages with JavaScript Objectives Explore the Document Object Model Add content using a script Trigger a script using an event handler Create

More information

Regular Expressions. Regular expressions are a powerful search-and-replace technique that is widely used in other environments (such as Unix and Perl)

Regular Expressions. Regular expressions are a powerful search-and-replace technique that is widely used in other environments (such as Unix and Perl) Regular Expressions Regular expressions are a powerful search-and-replace technique that is widely used in other environments (such as Unix and Perl) JavaScript started supporting regular expressions in

More information

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

UNIT -II. Language-History and Versions Introduction JavaScript in Perspective- UNIT -II Style Sheets: CSS-Introduction to Cascading Style Sheets-Features- Core Syntax-Style Sheets and HTML Style Rle Cascading and Inheritance-Text Properties-Box Model Normal Flow Box Layout- Beyond

More information

CSC Web Programming. Introduction to JavaScript

CSC Web Programming. Introduction to JavaScript CSC 242 - Web Programming Introduction to JavaScript JavaScript JavaScript is a client-side scripting language the code is executed by the web browser JavaScript is an embedded language it relies on its

More information

Program and Graphical User Interface Design

Program and Graphical User Interface Design CHAPTER 2 Program and Graphical User Interface Design OBJECTIVES You will have mastered the material in this chapter when you can: Open and close Visual Studio 2010 Create a Visual Basic 2010 Windows Application

More information

Cpt S 122 Data Structures. Introduction to C++ Part II

Cpt S 122 Data Structures. Introduction to C++ Part II Cpt S 122 Data Structures Introduction to C++ Part II Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Topics Objectives Defining class with a member function

More information

Topics. Class Basics and Benefits Creating Objects.NET Architecture and Base Class Libraries 3-2

Topics. Class Basics and Benefits Creating Objects.NET Architecture and Base Class Libraries 3-2 Classes & Objects Topics Class Basics and Benefits Creating Objects.NET Architecture and Base Class Libraries 3-2 Object-Oriented Programming Classes combine data and the methods (code) to manipulate the

More information

Session 6. JavaScript Part 1. Reading

Session 6. JavaScript Part 1. Reading Session 6 JavaScript Part 1 Reading Reading Wikipedia en.wikipedia.org/wiki/javascript Web Developers Notes www.webdevelopersnotes.com/tutorials/javascript/ JavaScript Debugging www.w3schools.com/js/js_debugging.asp

More information

Chapter 3 - Simple JavaScript - Programming Basics. Lesson 1 - JavaScript: What is it and what does it look like?

Chapter 3 - Simple JavaScript - Programming Basics. Lesson 1 - JavaScript: What is it and what does it look like? Chapter 3 - Simple JavaScript - Programming Basics Lesson 1 - JavaScript: What is it and what does it look like? PP presentation JavaScript.ppt. Lab 3.1. Lesson 2 - JavaScript Comments, document.write(),

More information

Client-Side Web Technologies. CSS Part I

Client-Side Web Technologies. CSS Part I Client-Side Web Technologies CSS Part I Topics Style declarations Style sources Selectors Selector specificity The cascade and inheritance Values and units CSS Cascading Style Sheets CSS specifies the

More information

Quick.JS Documentation

Quick.JS Documentation Quick.JS Documentation Release v0.6.1-beta Michael Krause Jul 22, 2017 Contents 1 Installing and Setting Up 1 1.1 Installation................................................ 1 1.2 Setup...................................................

More information

So, if you receive data from a server, in JSON format, you can use it like any other JavaScript object.

So, if you receive data from a server, in JSON format, you can use it like any other JavaScript object. What is JSON? JSON stands for JavaScript Object Notation JSON is a lightweight data-interchange format JSON is "self-describing" and easy to understand JSON is language independent * JSON uses JavaScript

More information

HTML/CSS Lesson Plans

HTML/CSS Lesson Plans HTML/CSS Lesson Plans Course Outline 8 lessons x 1 hour Class size: 15-25 students Age: 10-12 years Requirements Computer for each student (or pair) and a classroom projector Pencil and paper Internet

More information

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

UI Course HTML: (Html, CSS, JavaScript, JQuery, Bootstrap, AngularJS) Introduction. The World Wide Web (WWW) and history of HTML UI Course (Html, CSS, JavaScript, JQuery, Bootstrap, AngularJS) HTML: Introduction The World Wide Web (WWW) and history of HTML Hypertext and Hypertext Markup Language Why HTML Prerequisites Objective

More information

LAMBDA EXPRESSIONS. Summer 2018

LAMBDA EXPRESSIONS. Summer 2018 LAMBDA EXPRESSIONS Summer 2018 LAMBDA EXPRESSIONS USES Introduced in Java SE 8, lambda expressions are a way to create single-method classes in your code in a much less cumbersome manner than anonymous

More information

Programming for Engineers Introduction to C

Programming for Engineers Introduction to C Programming for Engineers Introduction to C ICEN 200 Spring 2018 Prof. Dola Saha 1 Simple Program 2 Comments // Fig. 2.1: fig02_01.c // A first program in C begin with //, indicating that these two lines

More information

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

Web Programming and Design. MPT Junior Cycle Tutor: Tamara Demonstrators: Aaron, Marion, Hugh Web Programming and Design MPT Junior Cycle Tutor: Tamara Demonstrators: Aaron, Marion, Hugh Plan for the next 5 weeks: Introduction to HTML tags, creating our template file Introduction to CSS and style

More information

a Why JavaScript? jonkv interactivity on the web CGI JavaScript Java Applets Netscape LiveScript JavaScript 1: Example

a Why JavaScript? jonkv interactivity on the web CGI JavaScript Java Applets Netscape LiveScript JavaScript 1: Example Why JavaScript? 2 JavaScript JavaScript the language Web page manipulation with JavaScript and the DOM 1994 1995: Wanted interactivity on the web Server side interactivity: CGI Common Gateway Interface

More information

Visual C# Instructor s Manual Table of Contents

Visual C# Instructor s Manual Table of Contents Visual C# 2005 2-1 Chapter 2 Using Data At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class Discussion Topics Additional Projects Additional Resources Key Terms

More information

STUDENT LESSON A10 The String Class

STUDENT LESSON A10 The String Class STUDENT LESSON A10 The String Class Java Curriculum for AP Computer Science, Student Lesson A10 1 STUDENT LESSON A10 The String Class INTRODUCTION: Strings are needed in many programming tasks. Much of

More information

Copyright. Trademarks Attachmate Corporation. All rights reserved. USA Patents Pending. WRQ ReflectionVisual Basic User Guide

Copyright. Trademarks Attachmate Corporation. All rights reserved. USA Patents Pending. WRQ ReflectionVisual Basic User Guide PROGRAMMING WITH REFLECTION: VISUAL BASIC USER GUIDE WINDOWS XP WINDOWS 2000 WINDOWS SERVER 2003 WINDOWS 2000 SERVER WINDOWS TERMINAL SERVER CITRIX METAFRAME CITRIX METRAFRAME XP ENGLISH Copyright 1994-2006

More information

Javascript Arrays, Object & Functions

Javascript Arrays, Object & Functions Javascript Arrays, Object & Functions Agenda Creating & Using Arrays Creating & Using Objects Creating & Using Functions 2 Creating & Using Arrays Arrays are a type of object that are ordered by the index

More information

IT 374 C# and Applications/ IT695 C# Data Structures

IT 374 C# and Applications/ IT695 C# Data Structures IT 374 C# and Applications/ IT695 C# Data Structures Module 2.1: Introduction to C# App Programming Xianrong (Shawn) Zheng Spring 2017 1 Outline Introduction Creating a Simple App String Interpolation

More information

What is PHP? [1] Figure 1 [1]

What is PHP? [1] Figure 1 [1] PHP What is PHP? [1] PHP is an acronym for "PHP: Hypertext Preprocessor" PHP is a widely-used, open source scripting language PHP scripts are executed on the server PHP is free to download and use Figure

More information

AN OVERVIEW OF C, PART 3. CSE 130: Introduction to Programming in C Stony Brook University

AN OVERVIEW OF C, PART 3. CSE 130: Introduction to Programming in C Stony Brook University AN OVERVIEW OF C, PART 3 CSE 130: Introduction to Programming in C Stony Brook University FANCIER OUTPUT FORMATTING Recall that you can insert a text field width value into a printf() format specifier:

More information

VENTURE. Section 1. Lexical Elements. 1.1 Identifiers. 1.2 Keywords. 1.3 Literals

VENTURE. Section 1. Lexical Elements. 1.1 Identifiers. 1.2 Keywords. 1.3 Literals VENTURE COMS 4115 - Language Reference Manual Zach Adler (zpa2001), Ben Carlin (bc2620), Naina Sahrawat (ns3001), James Sands (js4597) Section 1. Lexical Elements 1.1 Identifiers An identifier in VENTURE

More information

Chapter 7 Applets. Answers

Chapter 7 Applets. Answers Chapter 7 Applets Answers 1. D The drawoval(x, y, width, height) method of graphics draws an empty oval within a bounding box, and accepts 4 int parameters. The x and y coordinates of the left/top point

More information

Such JavaScript Very Wow

Such JavaScript Very Wow Such JavaScript Very Wow Lecture 9 CGS 3066 Fall 2016 October 20, 2016 JavaScript Numbers JavaScript numbers can be written with, or without decimals. Extra large or extra small numbers can be written

More information

Netscape Introduction to the JavaScript Language

Netscape Introduction to the JavaScript Language Netscape Introduction to the JavaScript Language Netscape: Introduction to the JavaScript Language Eckart Walther Netscape Communications Serving Up: JavaScript Overview Server-side JavaScript LiveConnect:

More information

Java How to Program, 10/e. Copyright by Pearson Education, Inc. All Rights Reserved.

Java How to Program, 10/e. Copyright by Pearson Education, Inc. All Rights Reserved. Java How to Program, 10/e Education, Inc. All Rights Reserved. Each class you create becomes a new type that can be used to declare variables and create objects. You can declare new classes as needed;

More information

CGS 3066: Spring 2015 JavaScript Reference

CGS 3066: Spring 2015 JavaScript Reference CGS 3066: Spring 2015 JavaScript Reference Can also be used as a study guide. Only covers topics discussed in class. 1 Introduction JavaScript is a scripting language produced by Netscape for use within

More information

Anatomy of ActionScript. FlashPitt 09 - Intermediate ActionScript 3.0

Anatomy of ActionScript. FlashPitt 09 - Intermediate ActionScript 3.0 Anatomy of ActionScript Anatomy of ActionScript Anatomy of ActionScript Vocabulary Read the ActionScript Diagram Vocabulary Variables DataTyping Tracing Functions Scope Event Handlers Objects and Classes

More information

Lesson 5: Introduction to Events

Lesson 5: Introduction to Events JavaScript 101 5-1 Lesson 5: Introduction to Events OBJECTIVES: In this lesson you will learn about Event driven programming Events and event handlers The onclick event handler for hyperlinks The onclick

More information

GridLang: Grid Based Game Development Language Language Reference Manual. Programming Language and Translators - Spring 2017 Prof.

GridLang: Grid Based Game Development Language Language Reference Manual. Programming Language and Translators - Spring 2017 Prof. GridLang: Grid Based Game Development Language Language Reference Manual Programming Language and Translators - Spring 2017 Prof. Stephen Edwards Akshay Nagpal Dhruv Shekhawat Parth Panchmatia Sagar Damani

More information

1 Getting started with Processing

1 Getting started with Processing cisc3665, fall 2011, lab I.1 / prof sklar. 1 Getting started with Processing Processing is a sketch programming tool designed for use by non-technical people (e.g., artists, designers, musicians). For

More information

In the first class, you'll learn how to create a simple single-view app, following a 3-step process:

In the first class, you'll learn how to create a simple single-view app, following a 3-step process: Class 1 In the first class, you'll learn how to create a simple single-view app, following a 3-step process: 1. Design the app's user interface (UI) in Xcode's storyboard. 2. Open the assistant editor,

More information

IDM 232. Scripting for Interactive Digital Media II. IDM 232: Scripting for IDM II 1

IDM 232. Scripting for Interactive Digital Media II. IDM 232: Scripting for IDM II 1 IDM 232 Scripting for Interactive Digital Media II IDM 232: Scripting for IDM II 1 PHP HTML-embedded scripting language IDM 232: Scripting for IDM II 2 Before we dive into code, it's important to understand

More information

Dreamweaver CS 5.5. University Information Technology Services. Training, Outreach, Learning Technologies, and Video Production

Dreamweaver CS 5.5. University Information Technology Services. Training, Outreach, Learning Technologies, and Video Production Dreamweaver CS 5.5 Creating Web Pages with a Template University Information Technology Services Training, Outreach, Learning Technologies, and Video Production Copyright 2012 KSU Department of Information

More information

EnableBasic. The Enable Basic language. Modified by Admin on Sep 13, Parent page: Scripting Languages

EnableBasic. The Enable Basic language. Modified by Admin on Sep 13, Parent page: Scripting Languages EnableBasic Old Content - visit altium.com/documentation Modified by Admin on Sep 13, 2017 Parent page: Scripting Languages This Enable Basic Reference provides an overview of the structure of scripts

More information

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

Web Programming and Design. MPT Junior Cycle Tutor: Tamara Demonstrators: Aaron, Marion, Hugh Web Programming and Design MPT Junior Cycle Tutor: Tamara Demonstrators: Aaron, Marion, Hugh Plan for the next 5 weeks: Introduction to HTML tags, creating our template file Introduction to CSS and style

More information

Programming In Java Prof. Debasis Samanta Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

Programming In Java Prof. Debasis Samanta Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Programming In Java Prof. Debasis Samanta Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Lecture - 06 Demonstration II So, in the last lecture, we have learned

More information

Functions and Recursion

Functions and Recursion Functions and Recursion 1 Storage Classes Scope Rules Functions with Empty Parameter Lists Inline Functions References and Reference Parameters Default Arguments Unary Scope Resolution Operator Function

More information

CISC 1600 Lecture 2.4 Introduction to JavaScript

CISC 1600 Lecture 2.4 Introduction to JavaScript CISC 1600 Lecture 2.4 Introduction to JavaScript Topics: Javascript overview The DOM Variables and objects Selection and Repetition Functions A simple animation What is JavaScript? JavaScript is not Java

More information

d2vbaref.doc Page 1 of 22 05/11/02 14:21

d2vbaref.doc Page 1 of 22 05/11/02 14:21 Database Design 2 1. VBA or Macros?... 2 1.1 Advantages of VBA:... 2 1.2 When to use macros... 3 1.3 From here...... 3 2. A simple event procedure... 4 2.1 The code explained... 4 2.2 How does the error

More information

Fundamentals of Programming Session 4

Fundamentals of Programming Session 4 Fundamentals of Programming Session 4 Instructor: Reza Entezari-Maleki Email: entezari@ce.sharif.edu 1 Fall 2011 These slides are created using Deitel s slides, ( 1992-2010 by Pearson Education, Inc).

More information

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

JAVASCRIPT AND JQUERY: AN INTRODUCTION (WEB PROGRAMMING, X452.1) Technology & Information Management Instructor: Michael Kremer, Ph.D. Class 4 Professional Program: Data Administration and Management JAVASCRIPT AND JQUERY: AN INTRODUCTION (WEB PROGRAMMING, X452.1) AGENDA

More information

Chapter 4 Basics of JavaScript

Chapter 4 Basics of JavaScript Chapter 4 Basics of JavaScript JavaScript/EcmaScript References The official EcmaScript, third edition, specification http://www.ecma-international.org/publications/files/ecma-st/ecma-262.pdf A working

More information

Java Classes and Objects

Java Classes and Objects Table of contents 1 Introduction Case Study - Stack 2 3 Integer String Case Study - Stack Introduction Case Study - Stack Classes Template for creating objects Definition of State (What it knows) Definition

More information