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. Kubernetes TensorFlow 默认 特定 集群管理器 虚拟化技术

    Our goal is to foster an ecosystem of components and tools that relieve the burden of running applic ...

  2. ftp协议服务器与tinyhttp服务demo

    https://www.jianshu.com/p/fb9fcb69efc9 ....... https://www.jianshu.com/p/e9a2e0755496 ============== ...

  3. pycharm设置头文件模板(for mac)

    我们要达到的效果是每次新建一个.py文件都会有头文件,关于头文件的作用之前已做解释

  4. NOI Linux 快速入门指南

    目录 关于安装 NOI Linux 系统配置 网络 输入法 编辑器 1. gedit 打开 配置 外观展示 2. vim 打开 配置 使用 makefile 编译运行 1. 编写 makefile 2 ...

  5. 收集整理Idea常用配置及插件

    收集整理Idea常用配置及插件 一.IDEA配置 1.1 代码智能提示,忽略大小写 二.IDEA插件 2.1 Background Image Plus 2.2 Codota-代码智能提示 2.3 S ...

  6. Hive 报错

    hadoop hive任务失败,原因是GC overhead limit exceeded (OOM) GC Overhead Limit Exceeded error是java.lang.OutOf ...

  7. scanf()函数释疑(word找的,没源地址了)

    scanf()函数释疑(上) 一.序言 scanf()函数的控制串的使用 例1. #include "stdio.h" int main(void) { int a,b,c; sc ...

  8. 南阳ccpc C题 The Battle of Chibi && hdu5542 The Battle of Chibi (树状数组优化+dp)

    题意: 给你一个长度为n的数组,你需要从中找一个长度为m的严格上升子序列 问你最多能找到多少个 题解: 我们先对原序列从小到大排序,排序之后的序列就是一个上升序列 这里如果两个数相等的话,那么因为题目 ...

  9. java——接口、多态性、对象转型

    接口定义:  默认方法: 默认方法的作用: 如果在你的接口已经投入使用了,这个时候你想要在接口里面加一个方法,这个时候如果你加一个抽象方法的话,所有实现类都要改变源代码(因为实现类要把接口中的所有抽象 ...

  10. 一文带你认识Docker

    Docker是一个容器技术的应用,而底层是由于Linux容器实现的,Docker只是实现层. 一.Linux容器 1.隔离与共享 一台服务器运行着多个逻辑隔离的服务器进程,谁的运行环境都不希望影响到谁 ...