Or: “Everybody likes being given a glass of water.”
By Merlin Mann.
It's only advice for you because it had to be advice for me.
const selfReduce = function (fn, initialValue) { | |
let arr = Array.prototype.slice.call(this) | |
let res | |
let startIndex | |
if (initialValue === undefined) { | |
for (let i = 0; i < arr.length; i++) { | |
if (!arr.hasOwnProperty(i)) continue | |
startIndex = i | |
res = arr[i] | |
break |
const selfFilter = function (fn, context) { | |
let arr = Array.prototype.slice.call(this) | |
let filteredArr = [] | |
for (let i = 0; i < arr.length; i++) { | |
if(!arr.hasOwnProperty(i)) continue; | |
fn.call(context, arr[i], i, this) && filteredArr.push(arr[i]) | |
} | |
return filteredArr | |
} |
const selfMap = function (fn, context) { | |
let arr = Array.prototype.slice.call(this) | |
let mappedArr = Array() | |
for (let i = 0; i < arr.length; i++) { | |
if (!arr.hasOwnProperty(i)) continue; | |
mappedArr[i] = fn.call(context, arr[i], i, this) | |
} | |
return mappedArr | |
} |
Mute these words in your settings here: https://twitter.com/settings/muted_keywords | |
ActivityTweet | |
generic_activity_highlights | |
generic_activity_momentsbreaking | |
RankedOrganicTweet | |
suggest_activity | |
suggest_activity_feed | |
suggest_activity_highlights | |
suggest_activity_tweet |
const MY_DOMAIN = "agodrich.com" | |
const START_PAGE = "https://www.notion.so/gatsby-starter-notion-2c5e3d685aa341088d4cd8daca52fcc2" | |
const DISQUS_SHORTNAME = "agodrich" | |
addEventListener('fetch', event => { | |
event.respondWith(fetchAndApply(event.request)) | |
}) | |
const corsHeaders = { | |
"Access-Control-Allow-Origin": "*", |
let regex; | |
/* 匹配特定的字符串 */ | |
regex = /hello/; // 查找斜杠中的字符串(大小写敏感)……匹配 "hello", "hello123", "123hello123", "123hello",但不匹配 "hell0", "Hello" | |
regex = /hello/i; // 查找斜杠中的字符串(大小写不敏感)……匹配 "hello", "HelLo", "123HelLO" | |
regex = /hello/g; // 全局查找斜杠中的字符串…… | |
/* 通配符 */ | |
regex = /h.llo/; // "." 匹配除了换行外的任何一个字符……匹配 "hello", "hallo",但不匹配 "h\nllo" | |
regex = /h.*llo/; // "*" 匹配任何字符零次或多次,如 "hello", "heeeeeello", "hllo", "hwarwareallo" |
var value = 0; //window.value | |
Object.defineProperty(window, 'a', { | |
get: function() { | |
return this.value += 1; | |
} | |
}); | |
console.log(a===1 && a===2 && a===3) //true |
const a = { value : 0 }; | |
a.valueOf = function() { | |
return this.value += 1; | |
}; | |
console.log(a==1 && a==2 && a==3); //true |