You Don't Know the Hack tech in the frontend development

你所不知道的前端黑科技

css in js animation

https://www.ifchange.com/

live demo

See the Pen css in js 黑科技 by xgqfrms
(@xgqfrms) on CodePen.

js hover/over event

https://www.ifchange.com/about#done

onmouseover

https://developer.mozilla.org/en-US/docs/Web/API/Element/mouseover_event

// 单行写一个评级组件
let rate = 1;
"★★★★★☆☆☆☆☆".slice(5 - rate, 10 - rate);
// "★☆☆☆☆"

JavaScript 错误处理

// JavaScript Error & StackOverflow

const log = console.log;

try {
// throw new Error(`ts`);// ts
const err = {
type: "ts",
message: "ts error",
};
// throw new Error(err);
throw new Error(JSON.stringify(err));
} catch (e) {
log(e, typeof e, e.message)
// Error: {"type":"ts","message":"ts error"}
// "object" "{"type":"ts","message":"ts error"}"
const obj = JSON.parse(e.message)
log(obj)
const {
type,
message,
} = obj;
window.parent.location.href = `https://stackoverflow.com/search?q=[${type}]+${message}`;
}
// JavaScript Error & StackOverflow

const log = console.log;

try {
const err = {
type: "ts",
message: "ts error",
};
throw new Error(JSON.stringify(err));
} catch (e) {
// log(e, typeof e, e.message)
const {
type,
message,
} = JSON.parse(e.message);
window.parent.location.href = `https://stackoverflow.com/search?q=[${type}]+${message}`;
}

CSS 黑科技

UI 结构检测,加 1px 边框

// UI 结构检测,加 1px 边框

[].forEach.call($$("*"), function(a){
a.style.outline="1px solid #"+(~~(Math.random()*(1<<24))).toString(16)
}) // OR
Array.prototype.forEach.call(document.querySelectorAll('*'), dom => dom.style.outline = `1px solid #${parseInt(Math.random() * Math.pow(2,24)).toString(16)}`);
void 0 === undefined
// true
Array(6).fill(8)

//  (6) [8, 8, 8, 8, 8, 8]

// 金融数字格式化
// 1234567890 --> 1,234,567,890 // 正则实现 const test1 = '1234567890'
const format = test.replace(/\B(?=(\d{3})+(?!\d))/g, ','); console.log(format);
// 1,234,567,890 // 非正则实现 function formatCash(str) {
return str.split('').reverse().reduce((prev, next, index) => {
return ((index % 3) ? next : (next + ',')) + prev
})
} console.log(formatCash('1234567890'));
// 1,234,567,890

refs

https://juejin.im/entry/5998f8396fb9a0247c6ec9cd


xgqfrms 2012-2020

www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!


You Don't Know the Hack tech in the frontend development的更多相关文章

  1. (转) [it-ebooks]电子书列表

    [it-ebooks]电子书列表   [2014]: Learning Objective-C by Developing iPhone Games || Leverage Xcode and Obj ...

  2. Frontend Development

    原文链接: https://github.com/dypsilon/frontend-dev-bookmarks Frontend Development Looking for something ...

  3. RednaxelaFX写的文章/回答的导航帖

    https://www.zhihu.com/people/rednaxelafx/answers http://hllvm.group.iteye.com/group/topic/44381#post ...

  4. 【转】Styling And Animating SVGs With CSS

    原文转自:http://www.smashingmagazine.com/2014/11/03/styling-and-animating-svgs-with-css/?utm_source=CSS- ...

  5. Top JavaScript Frameworks, Libraries & Tools and When to Use Them

    It seems almost every other week there is a new JavaScript library taking the web community by storm ...

  6. GitHub awesome Resource

    各种Awesome技术资源的资源聚合: https://github.com/sindresorhus/awesome Contents Platforms Programming Languages ...

  7. frontend-tools

    收集整理好用的前端开发利器(Collect good front-end development tools ) 1.w3cplus前端工具 2.jsfiddle在线JS代码调试工具 3.w3cfun ...

  8. 所有语言的Awesome(2)

    Curated list of awesome lists https://awesomeweekly.co https://github.com/sindresorhus/awesome ✨ Pre ...

  9. Tech Stuff - Mobile Browser ID (User-Agent) Strings

    Tech Stuff - Mobile Browser ID (User-Agent) Strings The non-mobile stuff is here (hint: you get jerk ...

随机推荐

  1. python 9学习 高级特性

    高级特性 掌握了Python的数据类型.  语句      和函数,基本上就可以编写出很多有用的程序了. 比如构造一个1, 3, 5, 7, ..., 99的列表,可以通过循环实现: L = [] n ...

  2. Java 字符串简介

    从概念上讲,Java 字符串就是 Unicode 字符序列.Java 没有内置的字符串类型,而是在标准 Java 类库中提供了一个预定义类,很自然地叫做 String.每个用双引号括起来的字符串都是 ...

  3. 在nodejs中创建cluster

    目录 简介 cluster集群 cluster详解 cluster中的event cluster中的方法 cluster中的属性 cluster中的worker 总结 在nodejs中创建cluste ...

  4. SpringMVC听课笔记(十四:异常处理)

    1. SpringMVC通过HandlerExceptionResolver处理程序的异常,包括Handler映射,数据绑定以及目标方法执行时发生的异常 2.SpringMVC提供的HandlerEx ...

  5. 【PY从0到1】第七节 函数

    # 7 第七节 函数 # 函数对于编程语言来说是一块重量级的内容. # 他可以实现或者简化编写的代码. # 编写好特定功能的函数后,就可以重复调用函数来完成任务. # 下面我们就用函数的形式来封装前面 ...

  6. linux下mysql基于mycat做主从复制和读写分离之基础篇

    Linux下mysql基于mycat实现主从复制和读写分离1.基础设施 两台虚拟机:172.20.79.232(主) 172.20.79.233(从) 1.1软件设施 mysql5.6.39 , my ...

  7. XV6学习(10)锁

    在包括XV6的绝大部分操作系统都是多个任务交错执行的.交错的一个原因是多核硬件:多核计算机的多个CPU核心独立执行计算,如XV6的RISC-V处理器.多个CPU核心共享物理内存,XV6利用这种共享来维 ...

  8. P1091 合唱队形(LIS)

    题目描述 NNN位同学站成一排,音乐老师要请其中的(N−KN-KN−K)位同学出列,使得剩下的KKK位同学排成合唱队形. 合唱队形是指这样的一种队形:设K位同学从左到右依次编号为1,2,-,K1,2, ...

  9. log查看工具log2console

    log查看工具log2console介绍:https://www.cnblogs.com/TianFang/archive/2013/03/27/2985296.html Log2Console日志监 ...

  10. PowerShell随笔1---背景

    既然是随笔,那就想到什么说什么,既会分享主题知识,也会分享一些其他技巧和个人学习方法,供交流. 我一般学习一个东西,我都会问几个问题: 这东西是什么? 这东西有什么用,为什么会出现,出现是为了解决什么 ...