Created
October 30, 2018 09:56
-
-
Save alpgul/1c0242712d018b03dbac73fa706e83f0 to your computer and use it in GitHub Desktop.
JavaScript Statements
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Semicolons ; | |
| var a, b, c; // Declare 3 variables | |
| a = 5; // Assign the value 5 to a | |
| b = 6; // Assign the value 6 to b | |
| c = a + b; // Assign the sum of a and b to c | |
| // one line | |
| a = 5; b = 6; c = a + b; | |
| //JavaScript White Space | |
| var person = "Hege"; | |
| var person="Hege"; | |
| var x = y + z; | |
| //JavaScript Line Length and Line Breaks | |
| document.getElementById("demo").innerHTML = | |
| "Hello Dolly!"; | |
| //JavaScript Code Blocks | |
| function myFunction() { | |
| document.getElementById("demo1").innerHTML = "Hello Dolly!"; | |
| document.getElementById("demo2").innerHTML = "How are you?"; | |
| } | |
| //JavaScript Keywords | |
| /* | |
| break Terminates a switch or a loop | |
| continue Jumps out of a loop and starts at the top | |
| debugger Stops the execution of JavaScript, and calls (if available) the debugging function | |
| do ... while Executes a block of statements, and repeats the block, while a condition is true | |
| for Marks a block of statements to be executed, as long as a condition is true | |
| function Declares a function | |
| if ... else Marks a block of statements to be executed, depending on a condition | |
| return Exits a function | |
| switch Marks a block of statements to be executed, depending on different cases | |
| try ... catch Implements error handling to a block of statements | |
| var Declares a variable | |
| */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment