Homelab, Linux, JS & ABAP (~˘▾˘)~
 

[JavaScript] Functions

/* Basic Function */
function reusableFunction() {
  console.log("Hello World");
}
reusableFunction();


/* Passing Values to Functions with Arguments */
function functionWithArgs(arg1, arg2 ) {
    console.log(arg1 + arg2);
}
functionWithArgs(1, 2); //returns 3


/* Global vs. Local Scope in Functions 
It is possible to have both local and global variables with the same name. 
When you do this, the local variable takes precedence over the global variable. */
var outerWear = "T-Shirt";
function myOutfit() {
  var outerWear = "sweater"
  return outerWear;
}
myOutfit(); //returns "sweater"

[JavaScript] Comparsion Operators

/* Equality Operator (type conversion / type coercion) */
1   ==  1   // true
1   ==  2   // false
1   == '1'  // true
"3" ==  3   // true


/* Strict Equality Operator (no type conversion) */
3 ===  3   // true
3 === '3'  // false


/* Inequality Operator (type conversion) */
1 !=  2     // true
1 != "1"    // false
1 != '1'    // false
1 != true   // false
0 != false  // false

/* Strict Inequality Operator (no type conversion) */
3 !==  3   // false
3 !== '3'  // true
4 !==  3   // true

/*Greater Than Operator (type conversion) */
5   >  3   // true
7   > '3'  // true
2   >  3   // false
'1' >  9   // false

/* Greater Than Or Equal To Operator (type conversion) */ 
6   >=  6   // true
7   >= '3'  // true
2   >=  3   // false
'7' >=  9   // false

/* Less Than Operator (type conversion) */
2   < 5  // true
'3' < 7  // true
5   < 5  // false
3   < 2  // false
'8' < 4  // false

/* Less Than Or Equal To Operator (type conversion) */
4   <= 5  // true
'7' <= 7  // true
5   <= 5  // true
3   <= 2  // false
'8' <= 4  // false