Skip to content

Instantly share code, notes, and snippets.

View positiveko's full-sized avatar
😇

Positive Ko positiveko

😇
  • Seoul
View GitHub Profile
@darshna09
darshna09 / myHashTable.js
Last active November 14, 2021 17:27
Hash Table Implementation in JavaScript
class HashTable {
constructor(size) {
this.data = new Array(size);
}
// Hash Function
_hash(key) {
let hash = 0;
for(let i = 0; i < key.length; i++) {
hash = (hash + key.charCodeAt(i) * i) % this.data.length;
@jesstelford
jesstelford / event-loop.md
Last active June 7, 2024 17:12
What is the JS Event Loop and Call Stack?

Regular Event Loop

This shows the execution order given JavaScript's Call Stack, Event Loop, and any asynchronous APIs provided in the JS execution environment (in this example; Web APIs in a Browser environment)


Given the code

@leofavre
leofavre / getEventPath.js
Last active August 23, 2021 06:50
This function serves as a polyfill for Event.composedPath()
/**
* Returns an array with all DOM elements affected by an event.
* The function serves as a polyfill for
* [`Event.composedPath()`](https://dom.spec.whatwg.org/#dom-event-composedpath).
*
* @category Event
* @param {Event} evt The triggered event.
* @return {Array.<HTMLElement>} The DOM elements affected by the event.
*
* @example
@paulirish
paulirish / what-forces-layout.md
Last active July 17, 2024 00:51
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent