Download presentation
Presentation is loading. Please wait.
1
Reviewing key concepts
JavaScript Reviewing key concepts
2
3 BIG IDEAS Assignment Statements Functions Forms
3
Idea 1: assignment statements
4
Holding information A computer doesn’t understand values
It takes locations and does what you tell it It knows about “cubby holes” A JavaScript Statement Takes information from a cubby hole Does what you say And then puts it where you say Holding information
5
A = B + C; Cubby Hole 2: add this value Cubby Hole 3: place it here
Cubby Hole 1: take this value example
6
CUBBY HOLES 3 types of cubby holes Differences Fields in a form
Function input and output Specially defined ones Differences Some you can only read Some you can only write Some you can do both CUBBY HOLES
7
using Functions
8
Output Black Box Inputs
9
Return Parameters Function Cubby hole I can just write
Cubby holes I can just read
10
Isolation A function can be called from ANYWHERE
It knows nothing about the outside world You need to tell it EVERYTHING it needs Isolation
11
The rules The order of the parameters matter Only a single output
5 - 3 different than 3 -5 Any number of parameters can be defined Fixed for any specific function Only a single output Optional in general Same for any specific function The rules
12
Returning a value Use the function as a value Contrast with
form.field.value = function(parm1, parm2); difference = subtract(minuhend,subtrahend); Contrast with alert(string); append(form.field.value,’end’); Returning a value
13
creating Functions
14
Writing: alert, log Conversions: strings and numbers Many more: google them Existing functions
15
Need to define Inputs Outputs What to do Building our own
16
Inputs: read only These are the parameters
Order matters Need a way to reference them Position 1, position 2, … Cubby holes Better to use meaningful names Each name is just a pointer to the cubby hole Inputs: read only
17
output: write once Use a RETURN statement
A write-once cubby hole Only way to access is the RETURN statement Once you set it, the function is ended Can have a simple value or more (e.g., concatenating strings) output: write once
18
WHAT TO DO Series of statements: the recipe Can use
Assignment statements Function calls Can use Literals (5, “ “) parameters Specially defined locations (variables) WHAT TO DO
19
Idea 3: Forms
20
Form fields are cubby holes
Two cubby holes that we have learned about: value: something that can be changed src: the picture file Form fields are cubby holes
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.