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
// callback executer | |
let y = function(doCallBack) { | |
console.log("This is dependent function expression which will inquire callback"); | |
doCallBack(); /* doCallBack parameter defined and executed itself inside dependant function expression ensure callback as argument will be inquired and returned subsequently */ | |
}; | |
// calback ifself | |
let x = function() { | |
console.log('This is the body of independent function expression, which says: "I am callback called as argument"'); | |
}; |
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
// Constructor function for myObj | |
function myObj(firstValue, secondValue, thirdValue, undefined) { | |
this.firstKey = firstValue; // disabled due null | |
this.secondKey = secondValue; // second parameter is enabled; all the rest are disabled in console output; | |
this.thirdKey = thirdValue; // disabled due null; | |
this.nKey = undefined; // disabled due undefined; | |
} | |
// Create a myObject; Object Instance name ::after keyword "new" must match name of the function constructor name defined above! | |
var userInput = new myObj("Index1userA", "JavaScript", "Index3userC", "Index4userD"); /* Basically, what User1 inputs inside parantheses |
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
<!DOCTYPE html> | |
<html> | |
<body> | |
<p><u>Example list</u>:</p> | |
<ul id="myList"><!-- Delete this firstChild text-comment node in order to get Absence of whitespace as HTML element presented in yellow color. Otherwise Absence of whitespace as HTML element is described as undefined and Presence of whitespace as HTML element presented in red color p.s avoid ENTER in this example i.e manipulate only with comment area --><li id="demo1">Absence of whitespace</li><li id="demo2">Presence of whitespace</li></ul> | |
<p><b>Click the button to get the HTML content of the list's first child node:</b><br> a) result in yellow color or "Absence of whitespace" is undefined + case b)<br> b) result in red color as "Presence of whitespace"</p> | |
<button onclick="myFunction()">Try it</button> |
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
function eHandler(eventObjectParameterGoes1st) { | |
/* var objTarget = eventObjectParameterGoes1st.target; | |
objTarget.style.backgroundColor = "yellow"; */ | |
eventObjectParameterGoes1st.target.style.backgroundColor = "yellow"; // _if using shortcut | |
} | |
var variableWin = this; // keyword THIS represent [object Window] in JS | |
variableWin.addEventListener('mouseover', function (eventObjectParameterGoes1st) { | |
eHandler (eventObjectParameterGoes1st); }, false); |
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
function eHandler(e, addCustomColor) { | |
var objTarget = e.target; | |
objTarget.style.backgroundColor = addCustomColor;} | |
var variableWin = this; // keyword THIS represent [object Window] in JS | |
variableWin.addEventListener('mouseover', function (e) { | |
eHandler (e, 'yellow'); }, false); |
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
var someVariable = new Object; | |
// same alternative written below; | |
var someVariable = {}; // {object Object syntax} |
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
var i = 0; // define zero number to start loop at | |
while (i < 6) { // start at zero | |
if (i === 3) { // when loop reaches number 3... | |
break; //... break the loop and return 3 as terminal number of the loop | |
} | |
i = i + 1; // alter variable i to 3. Start at 0, when i = 1, when i = 2, when i = 3 BREAK! | |
} | |
console.log(i); // console variable i | |
// expected output: 3 |
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
var paramArr = [" love you", " when you smile"]; | |
[arg1, arg2] = paramArr; | |
// [modified] const [arg1, arg2] = paramArr; | |
function iLoveYou (arg1, arg2) { | |
return arg1 + arg2; | |
} | |
iLoveYou(arg1, ""); |
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
for (var counter = 10; counter > 0; counter--) { | |
console.log(counter) | |
} |
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
var NumbersToOne = { | |
[Symbol.iterator]: ()=> { | |
var i = 10; | |
return { | |
prev: ()=> { | |
if (i > 0) {return { value: i--, done: false };} | |
else if (i == 0) {{return { value: i--, done: true };} | |
} | |
} | |
}; |
OlderNewer