View component-create.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
// 8-9 March 2023 | |
// component.create | |
// factory pattern to create worker-like component objects or actors (eventually) | |
// no big plans for expansion, just an illustration; however, | |
// a couple methods trying to wriggle into the implementation include: | |
// 1. extend()...? maybe. | |
// 2. terminate() + onterminate()...? maybe. | |
// suppose we could turn this into a closure and track each created object |
View merge-style.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
// 3-6 March 2023 | |
// style attributes vs. style properties | |
// differences between replace vs. merge | |
// replacing props vs. replacing attributes | |
// no surprises | |
// merging props vs. merging attributes | |
// at least one surprise, namely, that adding a style property | |
// creates a style attribute on elements without one initially. |
View intersection.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
// 2 March 2023 | |
// intersections from more than two arrays | |
// goaded by https://frontendroom.com/intersection-of-multiple-arrays-in-js/ | |
// works on arrays of values and arrays of objects with a single key; | |
// not sure I agree with the multiple keys matching output. | |
// values | |
var a = ["Item 1", "Item 2", "Item 3", "Item 4", "Item 5", "Item 6", "Item 7"] |
View is-class.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
// 25 February 2023 | |
// detect whether something is a class in JavaScript, not just a function. | |
// warning: this is not tamper-proof. | |
// @webreflection figured this out | |
// https://stackoverflow.com/questions/30758961/how-to-check-if-a-variable-is-an-es6-class-declaration/75567955#75567955 | |
// The test? | |
// The variable is typeof function and its prototype field is not writable. |
View lift-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
// 17 February 2023 | |
// lift parts out of a value | |
// using the Object constructor guard | |
function lift(v, key) { | |
var o = Object(v); | |
return Object.hasOwn(o, key) | |
? o[key] | |
: undefined; |
View partial-equal.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
// 5 February 2023 | |
// partial-equal in JavaScript | |
// inspired by https://brandur.org/fragments/partial-equal | |
// compare an object's values to a minimal "schema" which can be a primitive, | |
// allows extra fields on the compared object but expected fields must match | |
// expected values, including symbols as field names and field values; | |
// first failure terminates, logs a warning. |
View Σμυρναιικος-μπαλος.txt
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
έχεις το χρώμα της αυγής, | |
και τον αγγέλων μοιάζεις, | |
με τα γλυκά ματάκια σου, | |
τον ήλιο τον σκεπάζεις | |
you have the color of dawn, | |
and the angel you look like, | |
with your sweet eyes, | |
you cover the sun |
View queueMicrotask-vs-promise-sequence.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
// 13 January 2023 | |
// what is the order of processing when using queueMicrotask? | |
// synchronous sequence | |
// microtask | |
// promise resolution | |
queueMicrotask((_) => { | |
console.log(_, "task"); | |
}); |
View mutation-observer-on-detached-elements.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
// 31 december 2022 | |
// MutationObserver works on detached Elements | |
// define an element to watch for changes | |
var targetNode = document.createElement("p"); | |
targetNode.setAttribute("data-test", "initial value"); | |
targetNode.innerHTML = "Some <b>bold</b> ideas."; | |
// define callback with reference to the targetNode | |
function callback(mutationList, observer) { |
View diff-squares.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
// 26 Dec 2022 | |
// A diversion. | |
// Find the difference between the square of the sum of the numbers | |
// from 1 to n, and the sum of the squares from 1 to n. | |
function squareOfSum(n) { | |
if (+n !== +n) { | |
return 0 | |
} |
NewerOlder