Loading...
ES5 let arr = [1, 2, 3, 2, 4]for循环 for (let i = 0; i < arr.length; i++) { console.log(arr[i]) }forEach() 没有返回值,只是针对每个元素调用func arr.forEach(function(elem,...
关于原生JS的for循环有很多种写法。一、一般用for循环的方法: for(var i=0;i<arr.length;i++){ console.log(i); console.log(arr[i]); }很多人都这么写,但是每次循环都读取一次arr.length;二、第二种写法: for(var i=0,len=arr.length;...
作为前端,不可避免的经常对浏览器地址进行操作,要获取浏览器的参数,下面总结下浏览器获取参数的方法,在开发过程中,可以把这段代码封装成公共类,这样需要的时候调用就可以了。function getParam(name){ var search = document.location.search; var pattern = new RegExp("[?&]&q...
JS中获取时间new date()的用法获取时间:var myDate = new Date();//获取系统当前时间 获取特定格式的时间: myDate.getYear(); //获取当前年份(2位) myDate.getFullYear(); //获取完整的年份(4位,1970-????) myDate.getMonth(); //获取当前月份(0-11,0代表1月) myDate...
页面布局<section class="sec-wrapper"><header class="head-top">页面头部</header> <section class="main-section"> <div class="div-wrapper cl...