CS346 Javascript-41 Module 4 JavaScript Functions.

Slides:



Advertisements
Similar presentations
1 What is JavaScript? JavaScript was designed to add interactivity to HTML pages JavaScript is a scripting language A scripting language is a lightweight.
Advertisements

Introducing JavaScript
1 COMM 1213 H1 COMP 4923 X1 JavaScript 1 (Readings: Ch. 10, 11 Knuckles)
ECMM6018 Enterprise Networking For Electronic Commerce Tutorial 4 Client Side Scripting JavaScript Looping.
The Web Warrior Guide to Web Design Technologies
JavaScript, Fourth Edition
JavaScript, Third Edition
XP Tutorial 1 New Perspectives on JavaScript, Comprehensive1 Introducing JavaScript Hiding Addresses from Spammers.
Lesson15. JavaScript Objects Objects encapsulate data (properties) and behavior(methods); the properties and the methods of an object are tied together.
Identifiers and Assignment Statements. Data structures In any programming language you need to refer to data The simplest way is with the actual data.
Using Data Active Server Pages Objectives In this chapter, you will: Learn about variables and constants Explore application and session variables Learn.
Introduction to PHP and Server Side Technology. Slide 2 PHP History Created in 1995 PHP 5.0 is the current version It’s been around since 2004.
CS346 - Javascript 1, 21 Module 1 Introduction to JavaScript CS346.
JavaScript, Fifth Edition Chapter 1 Introduction to JavaScript.
Programming with JavaScript (Chapter 10). XP Various things Midterm grades: Friday Winter Career Fair – Thursday, April 28, 2011 (11 am to 3 pm). – MAC.
CISC474 - JavaScript 03/02/2011. Some Background… Great JavaScript Guides: –
CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad GM-IT CIIT Islamabad CIIT Virtual Campus, CIIT COMSATS Institute.
2440: 211 Interactive Web Programming Expressions & Operators.
Tutorial 2 Variables and Objects. Working with Variables and Objects Variables (or identifiers) –Values stored in computer memory locations –Value can.
Javascript. Outline Introduction Fundamental of JavaScript Javascript events management DOM and Dynamic HTML (DHTML)
1 JavaScript in Context. Server-Side Programming.
TUTORIAL 10: PROGRAMMING WITH JAVASCRIPT Session 2: What is JavaScript?
Chapter 6 Object-Oriented Java Script JavaScript, Third Edition.
Chapter 4 Procedural Methods. Learning Java through Alice © Daly and Wrigley Objectives Identify classes, objects, and methods. Identify the difference.
DHTML AND JAVASCRIPT Genetic Computer School LESSON 5 INTRODUCTION JAVASCRIPT G H E F.
WDMD 170 – UW Stevens Point 1 WDMD 170 Internet Languages eLesson: Variables, Functions and Events (there is an audio component to this eLesson) © Dr.
CS346 Javascript -3 Module 3 JavaScript Variables.
Chapter 3 Functions, Events, and Control Structures JavaScript, Third Edition.
JavaScript Syntax, how to use it in a HTML document
Chapter 2: Variables, Functions, Objects, and Events JavaScript - Introductory.
VARIABLES AND DATA TYPES Chapter2:part1 1. Objectives: By the end of this section you should: Understand what the variables are and why they are used.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
JavaScript. JavaScript is the programming language of HTML and the Web. Easy to learn One of the 3 languages of all developers MUST learn: 1. HTML to.
4. Javascript M. Udin Harun Al Rasyid, S.Kom, Ph.D Lab Jaringan Komputer (C-307) Desain.
1 Server versus Client-Side Programming Server-SideClient-Side.
Structured Programming (4 Credits) HNDIT Week 2 – Learning Outcomes Design an algorithmic solution for simple problem such as computation of a factorial,
1 JavaScript in Context. Server-Side Programming.
Tutorial 10 Programming with JavaScript. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Learn the history of JavaScript.
1 Variables and Arithmetic Operators in JavaScript.
MTA EXAM HTML5 Application Development Fundamentals.
Support standard JavaScript code with static typing Encapsulation through classes and modules Support for constructors, properties and.
Batch Files More flow of control Copyright © by Curt Hill.
JavaScript Variables Like other programming languages, JavaScript variables are a container that contains a value - a value that can be changed/fixed.
Shell Scripting September 27, 2004 Class Meeting 6, Part II * Notes adapted by Lenwood Heath from previous work by other members of the CS faculty at Virginia.
JavaScript Variables. Definition A variable is a "container" for information you want to store. A variable's value can change during the script.
Module 1 Introduction to JavaScript
>> Introduction to JavaScript
>> JavaScript: Location, Functions and Objects
PHP 5 Syntax.
JAVA Script : Functions Ashima Wadhwa
JavaScript Loops.
Revision Lecture
Functions Comp 205 Fall ‘17.
Variables and Arithmetic Operators in JavaScript
4. Javascript Pemrograman Web I Program Studi Teknik Informatika
JavaScript.
Section 3.2c Strings and Method Signatures
Chapter 19 JavaScript.
Chapter 4 Procedural Methods.
Javascript: variables and parameters
T. Jumana Abu Shmais – AOU - Riyadh
JavaScript What is JavaScript? What can JavaScript do?
Variables Kevin Harville.
Chapter 7 Procedural Methods.
JavaScript What is JavaScript? What can JavaScript do?
Tutorial 10: Programming with javascript
Java Script Siddharth Srivastava.
JavaScript: Introduction to Scripting
Presentation transcript:

CS346 Javascript-41 Module 4 JavaScript Functions

CS346 Javascript-42 Functions  Function — allows you to treat a related group of statements as a single unit  The syntax for defining a function is: function nameOfFunction (parameters) { statements; }

CS346 Javascript-43 Returning Values  A return statement ensures that a function returns a specific value to the main script This is done using the return keyword  You are not required to return a value from a function When a function performs a calculation it normally wants to receive a return value  There is no void/type for the return value

CS346 Javascript-44 Function Example Function #1 Example <!-- Hide var message = "I came from a function defined in head!"; function prnMsg() { document.write(message); } // Unhide -->

CS346 Javascript-45 Function Return Example Function #3 Example - Returning A Value <!-- Hide function getAvg(num1,num2,num3) { var avgResult = (num1+num2+num3)/3; return(avgResult); } // UnHide -->

CS346 Javascript-46 Naming Functions  Functions in JavaScript are case sensitive Must begin with a letter or an underscore character Cannot begin with a number Cannot contain any embedded spaces  Function names should reflect their purpose

CS346 Javascript-47 Examples  JS-4 Examples 4-1function.htm 4-2function.htm 4-3function.htm 4-4function.html