Last active
December 16, 2015 16:59
-
-
Save rizalp/5467448 to your computer and use it in GitHub Desktop.
JavaScript: Basic Variable & Function usage
#JavaScript #Functions
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
var variableName; //undefined | |
var helloWorld = "Hello, World!"; | |
var ten = 10; | |
var pi = 3.14; | |
var isBoolean = false; | |
var sum = 4 + 5, | |
difference = 4 - 5, | |
product = 4 * 5, | |
quotion = 4 / 5; | |
//Function declaration syntax | |
//hoisted, meaning you can place this function anywhere, and call this function anywhere | |
//JS Engine place it into the top of your code | |
function doSomething(){}; | |
//Function as Object | |
//not hoisted. You can only call this function after the function is defined | |
var doSomething = function(){}; | |
//this keyword, refers to global object, window (if executed in browser) | |
//or current execution context | |
alert( this.parseInt("10.2", 10) ); // 10 | |
alert( this.parseFloat("3.14159") ); // 3.14159 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment