Skip to content

Instantly share code, notes, and snippets.

View bitfishxyz's full-sized avatar
🐥
🐔🐔🥚🥚

medium003 bitfishxyz

🐥
🐔🐔🥚🥚
View GitHub Profile
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
body{
font-size: 150px;
}
function forEach(array, iteratee) {
let index = -1;
const length = array.length;
while (++index < length) {
iteratee(array[index], index);
}
return array;
}
function clone(target, map = new WeakMap()) {
<!DOCTYPE html>
<html lang="en">
<head>
<title>Document</title>
<style>
body, button{
font-size: 30px;
}
.red{
color: red;
const inBrowser = typeof window !== 'undefined'
const inWeex = typeof WXEnvironment !== 'undefined' && !!WXEnvironment.platform
const weexPlatform = inWeex && WXEnvironment.platform.toLowerCase()
const UA = inBrowser && window.navigator.userAgent.toLowerCase()
const isIE = UA && /msie|trident/.test(UA)
const isIE9 = UA && UA.indexOf('msie 9.0') > 0
const isEdge = UA && UA.indexOf('edge/') > 0
const isAndroid = (UA && UA.indexOf('android') > 0) || (weexPlatform === 'android')
const isIOS = (UA && /iphone|ipad|ipod|ios/.test(UA)) || (weexPlatform === 'ios')
const isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge
function isNative (Ctor){
return typeof Ctor === 'function' && /native code/.test(Ctor.toString())
}
function countFrequency(arr){
let result = new Map();
for(let element of arr){
if(result.get(element)) {
result.set(element, result.get(element) + 1)
} else {
result.set(element, 1)
}
}
return result;
// Get the price of apples from a fruit store
function getApplePrice(fruitStore) {
'start visiting the fruit store';
'walk to the fruit shop';
if('the fruit store was not open'){
'stop the process of visiting the fruit store';
return false;
}
'the apple purchase process begins';
'Declare a variable `lowestPriceFruitStore`, used to represent the fruit store with the lowest apple prices.';
for(fruitStore of [fruitStroe0, fruitStroe1, fruitStroe2]){
'start visiting the fruit store';
'walk to the fruit shop';
if('the fruit store was not open'){
'stop the process of visiting the fruit store';
}
'the apple purchase process begins';
// try to visit these 3 fruit stores in turn
for(fruitStore of [fruitStroe0, fruitStroe1, fruitStroe2]){
'start visiting the fruit store';
'walk to the fruit shop';
if('the fruit store was not open'){
'stop the process of visiting the fruit store';
}
class MyPromise{
constructor(executor) {
this.status = "pending";
this.value = undefined;
// This array is used to store all the onResolve functions in the chain call
this.resolveArr = [];
// // This array is used to store all the onReject functions in the chain call
this.rejectArr = [];