Professional Documents
Culture Documents
SE 1 (Web Development Course) : Section 5
SE 1 (Web Development Course) : Section 5
● JavaScript and Java are completely different languages, both in concept and
design
● Also used for mobile (react native) and desktop (Electorn JS) applications
○ In HTML, JavaScript code must be inserted between <script> and </script> tags.
○ Scripts can be placed in the <head> (example 1), or in the <body> (example 2 )
section of an HTML page, or in both.
2. External JavaScript
○ Scripts can also be placed in external files with .js ectension (example 3)
○ Steps:
○ var keyword:
■ Var variableName;
■ Example
○ Examples
Variables (3-3)
● More on JS scopes: var (global scope) vs let (local scope)
Vs.
Data types
Strings are written with single or double quotes
● Primitive data types of JS are string, number, Boolean, null, undefined
● Examples
Data types – more on string
● String methods and properties
○ Examples
○ Arrays use numbered indexes.
○ Objects use named indexes.
● Syntax: Called property
○ Examples
JS JSON (1-2)
● JSON
○ is a format for storing and transporting data (often from a server to a web
page).
○ * The JSON syntax is derived from JavaScript object notation syntax, but
the JSON format is text only.
JS JSON (2-2)
● JSON Syntax Rules
Try ○break
while& continue
- loops through a of loops:
block of code while a specified condition is true
• The break statement "jumps out" of a loop.
■ do/while - also loops through a block of code while a specified condition is true
• The continue statement "jumps over" one iteration in the loop.
JS Conditions (1-2)
● Conditional statements are used to perform different actions based on different
conditions
● Two ways for conditional statements:
○ IF
○ SWITCH
Try multiple conditions using operators ||, && and ternary operator
JS Conditions (2-2)
● Syntax:
● Examples
JS Functions
● A JavaScript function is a block of code designed to perform a particular task.
○ Target: You can reuse code: Define the code once, and use it many times.
● Syntax: using function keyword
● Examples
JavaScript Recourses
JavaScript Resourses
● The two best resources for learning JavaScript are:
○ W3Schools (https://www.w3schools.com/js/default.asp)