This file contains hidden or 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
/* events should be an object containing DOM event names as keys (click, keyup, hover...), with the values as objects having | |
* element "names" as keys, and event handler functions as values. E.g.: | |
* { | |
* click: { | |
* button1() { // handle button1 click }, | |
* button2() { // handle button2 click }, | |
* keyup { | |
* input1() { // handle input1 keyup } | |
* } | |
* } |
This file contains hidden or 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 str_length(str) { | |
let length = 0, nikud_chars = /[ְֱֲֳִֵֶַָֹֻּׁׂ]/; | |
for (let i=0,len=str.length;i<len;i++) | |
length += nikud_chars.test(str[i]) ? 0 : 1; | |
return length; | |
} |
This file contains hidden or 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
* `--trace_gc`: Logs garbage collection operations. | |
* `--inspect`: Runs node in debugging mode. open Chrome with `chrome://inspect` to see the debug session. |
This file contains hidden or 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
const G = (1 + Math.sqrt(5)) / 2; // Golden Ratio | |
Math.round(G ** n / Math.sqrt(5)); |
This file contains hidden or 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
// Check if objects are equal (have the same keys with the same values), all values must be primitives (no functions, objects or arrays) | |
function areObjectsEqual(obj1, obj2) { | |
let obj1KeysCount = 0; | |
for (const key in obj1) { | |
if (obj1[key] !== obj2[key]) return false; | |
obj1KeysCount++; | |
} | |
return Object.keys(obj2).length === obj1KeysCount; | |
} |
OlderNewer