摘录自小生方勤
-
评分工具
let rate = 2 '★★★★★☆☆☆☆☆'.substr(5 - rate, 5) '★★★★★☆☆☆☆☆'.substring(5 - rate, 10 - rate) '★★★★★☆☆☆☆☆'.slice(5 - rate, 10 - rate) -
js处理错误时直接定位错误原因
try { // something } catch (e) { window.location.href = 'http://stackoverflow.com/search?q=[js]+' + e.message } -
快速知道所有元素的边框
[].forEach.call($$("*"),function(a){ a.style.outline="1px solid #"+(~~(Math.random()*(1<<24))).toString(16) })或者
Array.prototype.forEach.call(document.querySelectorAll( * ), dom => dom.style.outline = `1px solid #${parseInt(Math.random() * Math.pow(2,24)).toString(16)}`) -
史上最快清除缓存方法
<a href="javascript:alert('清除成功!')">清除缓存<a/>