日前,有数码博主则曝光了一张显示为vivo S9系列的线下海报,从海报上可以看到,该机将会前置一颗4400万像素的主摄,根据爆料该机将会配备前置双摄。 根据目前曝光的信息汇总显示,vivo S9配备了…
js篇1.js数据类型原始类型和对象类型。原:number、string、boolean、null、undefined;对:object、function、regexp;2.类型转换强制类型转换 parseInt()、parseFloat()、隐式类型转换 四则运算转换为字符串 toString()3.数据类型检测
alert(typeof null);alert(typeof undefined);alert(typeof "abc"...
var num = '12334534534.43234' console.log(formatNum(num)) function formatNum(num){ num += '' // 如果包含,.或者小于1000 if(num.indexOf(',') > 0 || num*1<1000) return num // 拆分字符 var arr = num.split('.') var startStr = arr[0] ...
常用代码片段-前端篇
作者:WEBING
原文:点击 " 阅读原文 "
一、预加载图像
如果你的网页中需要使用大量初始不可见的(例如,悬停的)图像,那么可以预加载这些图像。
二、检查图像是否加载
有时为了继续脚本,你可能需要检查图像是否全部加载完毕。
...
class PromiseClone { constructor (process) { this.status = 'pending' this.msg = '' process(this.resolve.bind(this), this.reject.bind(this)) return this } resolve (val) { this.status = 'fulfilled' this.msg = val } reject (err) { ...
一、字符方法charAt方法和charCodeAt方法相同点:charAt方法和charCodeAt方法都接收一个参数,基于0的字符位置不同点:charAt方法是以单字符字符串的形式返回给定位置的那个字符charCodeAt方法获取到的不是字符而是字符编码还可以使用方括号加数字索引来访问字符串中特定的字符例如:var str = 'hello world';...
$('#content').on("mousewheel DOMMouseScroll", function (event) { // chrome & ie || // firefox var delta = (event.originalEvent.wheelDelta && (event.originalEvent.wheelDelta > 0 ? 1 : -1)) || (event.originalEvent.detail && (event.originalEvent.detail > 0 ...
function formatDate(now) { var y = now.getFullYear(); var m = now.getMonth() + 1; // 注意js里的月要加1 var d = now.getDate(); var h = now.getHours(); var m = now.getMinutes(); var s = now.getSeconds(); return y + "-" + m + "-" + d + " " + h + ":" + m + ":" + s; ...
var script=document.createElement("script"); script.setAttribute("type", "text/javascript"); script.setAttribute("src", "//code.jquery.com/jquery-1.8.3.min.js"); var heads = document.getElementsByTagName("head"); if(heads.length) heads[0].appendChild(script); else document.document...
function formatDate(now) { var y = now.getFullYear(); var m = now.getMonth() + 1; // 注意js里的月要加1 var d = now.getDate(); var h = now.getHours(); var m = now.getMinutes(); var s = now.getSeconds(); return y + "-" + m + "-" + d + " " + h + ":" + m + ":" + s; ...