Last active
December 24, 2015 09:49
-
-
Save sairion/6779728 to your computer and use it in GitHub Desktop.
Javascript_good_parts.js
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
/* | |
* default function param value | |
*/ | |
var getOuterWidth = function(Elem, Width, Padding){ | |
//assigning default value | |
Width = Width || 0; | |
Padding = Padding || 0; | |
//... | |
} | |
/* | |
* immediate invocation/excution function | |
* http://stackoverflow.com/questions/6719089/javascript-anonymous-function-immediate-invocation-execution-expression-vs-dec | |
* "If function is the first keyword on the line, the parser will interpret the rest of the line as a function declaration." | |
*/ | |
// 1. | |
(function(){ return 65535; })(); //65535 | |
// 2. | |
!function(){ return false; }(); //true | |
// 3. excute function immediately after declaration, giving params and assigning result value to lefthand. | |
var addResult = function(num1, num2){ return num1+num2 }( 1, 10 ); | |
console.log(addResult); // 11 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment