1/22
prelim topic
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
Javascript
Is a client-side scripting language - it is executed in the client (software) that the viewer is using (browser)
Each line is processed as it loads in the browser
Allows us to make interactive webpages
Is dynamic, event-based, async-friendly, prototype based, object-oriented language
Is popular because it runs pretty much on very client (iOS, Android, laptops) and on servers (Node.js)
Javascript Statements
Are codes to be executed by the browser
Tells the browser what to do
Commands to the browser
add semicolons at the end
can be grouped together into blocks using curly brackets
try…catch statement allows to test a block of code for errors
//
is the javascript single-line comment
/* */
Is the javascript multi-line comment
Javascript variables
are containers for storing information (ex: x=15; length=60.10;)
hold values or expressions
can hold a text value in name='“multimedia”
var statement can declare javascript variables: var x; var name;
They are case sensitive
Variable names
Arithmetic Operators
These perform arithmetic operations between values of the variables
Ex: Addition (+), Subtraction (-), Multiplication (*), Division (/), Modulus (%), Increment (+ +), Decrement (- -)
Assignment Operators
These assign values to variables
Ex: =, +, - =, * =, / =, % =
Comparison Operators
These determine equality or different between variables or values
Ex: Equal to (= =), Exactly equal to (= = =), Not equal (! =), Greater than (>), Less than (<), Greater than or equal to (>=), Lesser than or equal to (<=)
Logical Operators
These impose the logic between variables or values
Ex: AND (&&), OR (| |), NOT (!)
Conditional Operators
These assign value to variable based on some conditions
?:
if statement
to execute some code only if specified condition is true
if…else statement
to execute some code if the condition is true and another code if the condition is false
if…else if…else statement
To select one of many blocks of code to be executed
switch statement
To select one of many blocks of code to be executed
Javascript Looping
It executes the same block of codes
executes a specified number of times
execution can be controlled by some control logic
Ex: for, while, do…while statements
Ex: for…in to iterate through the elements of an array
Break
This breaks the loop and follows the code after the loop
Continue
This breaks the loop and continues with the next value
Javascript Functions
These can be called with the function name
Can also be executed by an event
Can have parameters and return statement
Javascript Events
These are actions that can be detected (Ex: OnMouseOver, onMouseOut)
Are normally associated with functions
Ex:
<input type=”text” size=”30” id=”email” onChange=”checkEmail()”>
Alert Box
This is a javascript popup box to make sure information comes through the user
Confirm Box
This is a javascript popup box to verify or accept something
Prompt Box
This is a javascript popup box for the user to input a value before entering a page