Skip to content

Instantly share code, notes, and snippets.

View shivam1283's full-sized avatar
🎯
Focusing

Shivam Yadav shivam1283

🎯
Focusing
View GitHub Profile
@shivam1283
shivam1283 / 1PromisesAndCallback.md
Last active December 21, 2022 08:31
JS concepts

Callback

function loadScript(src) {
  // creates a <script> tag and append it to the page
  // this causes the script with given src to start loading and run when complete
  let script = document.createElement('script');
  script.src = src;
  document.head.append(script);
}
@Rich-Harris
Rich-Harris / promise.js
Last active August 27, 2022 14:59
ES6 Promise polyfill
( function ( global ) {
'use strict';
var Promise, PENDING = {}, FULFILLED = {}, REJECTED = {};
if ( typeof global.Promise === 'function' ) {
Promise = global.Promise;
} else {
Promise = function ( callback ) {