Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
JavaScript: Basic Variable & Function usage #JavaScript #Functions
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
You can’t perform that action at this time.