Last active
December 23, 2015 01:59
-
-
Save mjumbewu/6563814 to your computer and use it in GitHub Desktop.
JS Review
This file contains 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
// We went over: | |
/* | |
* - What's JS used for | |
* - Modifying document structure (the HTML is not the webpage, like the | |
* blueprint is not the building) | |
* - Retrieving data from a server without a page reload | |
* - Widgets and usability | |
*/ | |
/* | |
* - Variables | |
* - Can be defined through assignment | |
* - Can be defined as function arguments | |
* - When not being assigned or used as function arguments, always recalling | |
* the variable value | |
*/ | |
var A = 'hello', // <-- assignment | |
B = 3, // <-- assignment | |
C = "goodbye"; // <-- assignment | |
alert(C); // <-- replacing with the value | |
var D = B + 2; // <-- both. make sense? | |
function do_something(X, Y) { // <-- function arguments | |
alert(X + Y); // <-- replacing with the values | |
} | |
/* | |
* - Functions | |
* - Are containers for one or more instructions | |
* - Can be "called" to run the contained instructions | |
*/ | |
function say_something(words) { | |
var sentence = words + '.'; | |
alert(sentence); | |
} | |
say_something("hello"); | |
say_something("this is a test"); | |
// You can copy and paste any of these into the Chrome/Firebug console to try | |
// them out. | |
// Also, we didn't go over this, but there are two ways to define functions. | |
// The following two are exactly the same: | |
function my_func(a, b, c) { | |
// ... | |
} | |
var my_func = function(a, b, c) { | |
// ... | |
} | |
// The reason is because a function is just a value. Functions are really | |
// powerful and immportant values. We'll do much more with them soon. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment