You Don't Know the Hack tech in the frontend development
You Don't Know the Hack tech in the frontend development
你所不知道的前端黑科技
css in js animation

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的更多相关文章
- (转) [it-ebooks]电子书列表
[it-ebooks]电子书列表 [2014]: Learning Objective-C by Developing iPhone Games || Leverage Xcode and Obj ...
- Frontend Development
原文链接: https://github.com/dypsilon/frontend-dev-bookmarks Frontend Development Looking for something ...
- RednaxelaFX写的文章/回答的导航帖
https://www.zhihu.com/people/rednaxelafx/answers http://hllvm.group.iteye.com/group/topic/44381#post ...
- 【转】Styling And Animating SVGs With CSS
原文转自:http://www.smashingmagazine.com/2014/11/03/styling-and-animating-svgs-with-css/?utm_source=CSS- ...
- 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 ...
- GitHub awesome Resource
各种Awesome技术资源的资源聚合: https://github.com/sindresorhus/awesome Contents Platforms Programming Languages ...
- frontend-tools
收集整理好用的前端开发利器(Collect good front-end development tools ) 1.w3cplus前端工具 2.jsfiddle在线JS代码调试工具 3.w3cfun ...
- 所有语言的Awesome(2)
Curated list of awesome lists https://awesomeweekly.co https://github.com/sindresorhus/awesome ✨ Pre ...
- 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 ...
随机推荐
- 获取控制台的错误信息 onerror
js 获取控制台的错误信息 https://www.bbsmax.com/A/Vx5ML2NmJN/ <!DOCTYPE html> <html lang="en" ...
- c++ 三五法则 自己理解
简介 三五法则规定了什么时候需要 1 拷贝构造函数 2 拷贝赋值函数 3 析构函数 1. 需要析构函数的类也需要拷贝构造函数和拷贝赋值函数. 通常,若一个类需要析构函数,则代表其合成的析构函数 ...
- 小步前进之WCF简介
WCF 前言 什么是WCF? 契约 合约 前言 在 .NET Framework2.0 以及前版本中,微软发展了 Web Service..NET Remoting 等通信支持. 如果要进行通信,对于 ...
- Excel通配符
数据科学交流群,群号:189158789 ,欢迎各位对数据科学感兴趣的小伙伴的加入!
- Java——入门“HelloWorld”
//Java程序的结构 //下面这个:外层框架 public class HellloWorld { // Java入口程序框架 //类名与文件名完全一样 public static void mai ...
- Spring Cloud与Eureka
Spring Cloud与Eureka 一.使用SpringCloud注册中心Eureka 1.1 Eureka和Zookeeper对比 1.1.1 Zookeeper保证CP 1.1.2 Eurek ...
- svn 启动项目报错,项目被lock
问题描述 问题解决 (一)Eclipse SVN 插件处理 (二)SVN 客户端处理 (三)删除lock文件 问题描述 在使用开发工具开发项目时(如Eclipse),在做项目的中途,有时候Eclips ...
- Flink-v1.12官方网站翻译-P013-Timely Stream Processing
及时的流处理 介绍 及时流处理是有状态流处理的一种扩展,其中时间在计算中起着一定的作用.其中,当你做时间序列分析时,当做基于某些时间段(通常称为窗口)的聚合时,或者当你做事件处理时,事件发生的时间很重 ...
- linux 一分钟搭建zookeeper linux 单机版(亲测可用)
wget https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/zookeeper-3.4.14/zookeeper-3.4.14.tar.gzt ...
- 初窥 Python 的 import 机制
本文适合有 Python 基础的小伙伴进阶学习 作者:pwwang 一.前言 本文基于开源项目: https://github.com/pwwang/python-import-system 补充扩展 ...