今天写了一个获取数组随机值的方法给同事,结果妹子同事一直不能理解为什么是Math.floor,而不用Math.round 方法:Array.prototype.getRandomItem=function(){ return this[Math.floor(Math.random ...
今天写了一个获取数组随机值的方法给同事,结果妹子同事一直不能理解为什么是Math.floor,而不用Math.round 方法:Array.prototype.getRandomItem=function(){ return this[Math.floor(Math.random ...
<html> <boby> </body> <script language="javascript"> window.onload = functio ...
前言 一位正在学习前端的菜鸟,虽菜,但还未放弃。 给大家画张图了解思路 以下是代码 ...
//文件结构var listInfo = [ { zTit: '网站首页', icon: './image/left.png', hic ...
...
获取数组最小值 ...
//取出数组中最大的值 var arrs = [11,152,21,5,31,23,90,102]; /* 1、定义一个变量num 2、让num的初始值是等于数组的第一个值 3、拿num去和数组中的每一个值做比较,如果num小于arr[i],那就让num = arr[i ...
面试给出的一道题, 给一个数组arr=[1,2,3,4,5],索引第二位插入'z',设计一个函数change,调用change(arr, 2, 'z')返回一个新数组[1,2,'z',3,4,5] 我想了两种办法: 第一种办法:先插入要添加的元素,再在将原数组后面的值添加在新数组 ...