-
Notifications
You must be signed in to change notification settings - Fork 0
/
variables.js
46 lines (35 loc) · 1.4 KB
/
variables.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// var Declares a variable
// let Declares a block variable
// const Declares a block constant that cannot be reassigned
// if Marks a block of statements to be executed on a condition
// switch Marks a block of statements to be executed in different cases
// for Marks a block of statements to be executed in a loop
// function Declares a function
// return Exits a function
// try Implements error handling to a block of statements
// Global Scope = Whole Code can use it.
// Local/Block Scope = Only used inside a function and cannot be accessed from outside .
// return = When a method returns a value, you can think of it
// as giving the value back to you, making it available for use
// in other parts of your code. return should be last statement in a function .
// Variables
let x = "One";
let y = "Two";
let z = "Three"
console.log(x);
console.log(y);
console.log(z);
// Declaration
let age;
let height;
let name;
// JS Outputs
// document.getElementById("innerOutput").innerHTML = 5 + 7; (This Goes Inside HTML)
// (Displays content in the browser)
// document.write (This Goes Inside HTML)
// (Deletes Everything After Used , Should Only Be Used For Testing)
// onclick="document.write(5 + 10)"
// onclick="window.alert(5 + 10)" (This Goes Inside HTML)
// (Displays an Alert Box in the Browser)
// onclick="window.print()" (This Goes Inside HTML)
// (Prints the browser page)