JAVASCRIPT Reviewing key concepts 3 BIG IDEAS Assignment
JAVASCRIPT Reviewing key concepts
3 BIG IDEAS Assignment Statements Functions Forms
IDEA 1: ASSIGNMENT STATEMENTS
A computer doesn’t understand values It takes locations and does what you tell it It knows about “cubby holes” A Java. Script Statement Takes Does And information from a cubby hole what you say then puts it where you say HOLDING INFORMATION
Cubby Hole 3: place it here Cubby Hole 2: add this value A = B + C; EXAMPLE Cubby Hole 1: take this value
3 types of cubby holes Fields in a form Differences Some you can only read Function input and output Some you can only write Specially defined ones Some you can do both CUBBY HOLES
USING FUNCTIONS
Inputs Black Box Output
Parameters Cubby holes I can just read Function Return Cubby hole I can just write
A function can be called from ANYWHERE It knows nothing about the outside world You need to tell it EVERYTHING it needs ISOLATION
The order of the parameters matter 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
Use the function as a value form. field. value difference Contrast = function(parm 1, parm 2); = subtract(minuhend, subtrahend); with alert(string); append(form. field. value, ’end’); RETURNING A VALUE
CREATING FUNCTIONS
Writing: alert, log Conversions: Many strings and numbers more: google them EXISTING FUNCTIONS
Need to define Inputs Outputs What to do BUILDING OUR OWN
These are the parameters Order Need matters a way to reference them Position Cubby Better Each 1, position 2, … holes to use meaningful names name is just a pointer to the cubby hole INPUTS: READ ONLY
Use A a RETURN statement write-once cubby hole Only Once way to access is the RETURN statement you set it, the function is ended Can have a simple value or more (e. g. , concatenating strings) OUTPUT: WRITE ONCE
Series of statements: the recipe Assignment Function Can statements calls use Literals (5, “ “) parameters Specially defined locations (variables) WHAT TO DO
IDEA 3: FORMS
Two cubby holes that we have learned about: value: src: something that can be changed the picture file FORM FIELDS ARE CUBBY HOLES
- Slides: 20