随笔分类 - js 随写
没啥算法含量, 只是觉得平常有点用, 省的每次写一遍。
如果有问题, 请指出, 共同学习。
摘要:* 重复零次或更多次(>= 0 次) + 重复一次或更多次(>= 1 次) ? 重复零次或一次(0次 或者 1次) {n} 重复n次 {n,} 重复n次或更多次 {n,m} 重复n到m次 . 匹配除换行符以外的任意字符 \w 匹配字母或数字或下划线或汉字 \s 匹配任意的空白符 \d 匹配数字 \b
阅读全文
摘要:先看下效果 github上做的一个音乐播放器: https://github.com/SorrowX/electron-music 中文歌曲 英文歌曲(如果有翻译的中文给回返回出去) 韩文歌曲 来看下解析歌词的类 使用姿势超级简单 new Lyric(data) data就是歌词文件中的对象 使用实
阅读全文
摘要:Document hi, 滚动指定的li到ul的顶部 1 2 3 4 5 6 ...
阅读全文
摘要:/** * Created by Sorrow.X on 2017/10/25. */ const http = require('http'); const url = require('url'); const net = require('net'); // 单例 let httpServer = (function() { let port = 8888; l...
阅读全文
摘要:var countDown = function (minute, callback) { var allSecond = minute * 60; var tickTimer = null; var start = function() { tickTimer = setI...
阅读全文
摘要:// 简单版 Function.prototype.bind = function(context) { var self = this; return function() { self.apply(context, arguments); }; ...
阅读全文
摘要:var Type = (function() { var Type = {}; for (var i = 0, type; type = ['Undefined', 'Null', 'Boolean', 'Number', 'String', 'Function', 'Array', 'Object'][i++]; ) { ...
阅读全文
摘要:function getLatelyDate(arrDate) { var arrMs = arrDate.map(function(time) { return new Date(time.replace(/\-/g, "\/")).getTime(); }, this); ...
阅读全文
摘要:Promise提供了all方法, 但是状态只有2种, 第一种是所有promise实例都成功则返回值组成一个数组,传递给p的回调函数; 第二种是有一个实例被rejected,状态就变成rejected,此时第一个被reject的实例的返回值,会传递给p的回调函数。 问题:其实我想要所有异步的结果,不管
阅读全文
摘要:/** * 数组分割成多数组 * @param {[type]} array 要分割的数组 * @param {[type]} size 每个数组的个数 * @return {[type]} 返回一个数组 */ let chunk = function (a...
阅读全文
摘要:class F { constructor() { // 获取新闻消息 this.newsCb = null; // 用户的回调 this.aNews = []; // 接口数据 this.getNewsTimer = null; ...
阅读全文
摘要:数组中的元素只能为数字 // 方法一 function unique(arr) { var i = 0, item, result = [], hash = {}; for (; (item = arr[i]) != null; i++) { ...
阅读全文
摘要:积累些常用的方法, 都是随写的, 不好之处, 望指出。 getRandomItem(arr)函数如下: 测试一下是否有重复的:
阅读全文

浙公网安备 33010602011771号