JavaScript Arrays are a very flexible data structure and used as lists, stacks, queues, tuples (e.g. pairs), etc. Some
Creating Arrays, reading and writing elements:
// Author: Sokdara Cheng | |
// Contact me for web or mobile app development using React or React Native | |
// https://chengsokdara.github.io | |
import React, { createContext, useContext, useReducer } from "react"; | |
import initialState from "./initialState"; // object of initial states | |
import reducer from "./reducer"; // https://reactjs.org/docs/hooks-reference.html#usereducer | |
const Store = createContext({ | |
dispatch: () => null, | |
state: initialState, | |
}); |
(function () { | |
File.prototype.arrayBuffer = File.prototype.arrayBuffer || myArrayBuffer; | |
Blob.prototype.arrayBuffer = Blob.prototype.arrayBuffer || myArrayBuffer; | |
function myArrayBuffer() { | |
// this: File or Blob | |
return new Promise((resolve) => { | |
let fr = new FileReader(); | |
fr.onload = () => { | |
resolve(fr.result); |
/** | |
* Shorthand function for document.createElement. Accepts and appends attributes to the newly created element and appends child element, if any. | |
* @param tagName The name of the element eg. a or script | |
* @param attributes Any additional attributes to add to the element after creating. Eg. href | |
* @param children Any child elements you want appended on creating this element, obviously they could be createElement calls as well | |
*/ | |
export function createElement(tagName, attributes, children) { | |
const ele = attributes === (void 0) | |
? document.createElement(tagName) | |
: Object.assign(document.createElement(tagName), attributes); |
axios({ | |
url: 'http://localhost:5000/static/example.pdf', | |
method: 'GET', | |
responseType: 'blob', // important | |
}).then((response) => { | |
const url = window.URL.createObjectURL(new Blob([response.data])); | |
const link = document.createElement('a'); | |
link.href = url; | |
link.setAttribute('download', 'file.pdf'); | |
document.body.appendChild(link); |
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.
elem.offsetLeft
, elem.offsetTop
, elem.offsetWidth
, elem.offsetHeight
, elem.offsetParent
People
:bowtie: |
😄 :smile: |
😆 :laughing: |
---|---|---|
😊 :blush: |
😃 :smiley: |
:relaxed: |
😏 :smirk: |
😍 :heart_eyes: |
😘 :kissing_heart: |
😚 :kissing_closed_eyes: |
😳 :flushed: |
😌 :relieved: |
😆 :satisfied: |
😁 :grin: |
😉 :wink: |
😜 :stuck_out_tongue_winking_eye: |
😝 :stuck_out_tongue_closed_eyes: |
😀 :grinning: |
😗 :kissing: |
😙 :kissing_smiling_eyes: |
😛 :stuck_out_tongue: |