![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
js面经
笑笑同学啊_
这个作者很懒,什么都没留下…
展开
-
类数组转数组的五种方法
方法一:Array.from(arguments)方法二:Array.prototype.slice.call(arguments)slice 方法 不传递参数,默认返回值是全部数组不能用 splice,返回值是删除的元素组成的数组Array.prototype.slice.call(arguments,0,arguments.length);方法三:for oflet res =[];for(let item of arguments){ res.push(item);..原创 2022-04-06 23:10:27 · 511 阅读 · 0 评论 -
二维数组的排列组合
题目一给出一个类型二维数组,每个数组中是一个类目(如[["红色", "绿色"], ["大号", "小号"]]),返回所有类型的组合结果([["红色", "大号"], ["红色", "小号"], ["绿色", "大号"], ["绿色", "小号"]])题目二输入 [[A, B], [a, b], [1, 2]]输出 [Aa1, Aa2, Ab1, Ab2, Ba1, Ba2, Bb1, Bb2]解题思路multi 函数参数:arrA,arrB返回值:两数组的所有组合功能:求两个数组之积原创 2022-04-04 20:01:11 · 1168 阅读 · 2 评论 -
js快速排序-(搬运+理解,从视频到文字)
视频理解快排思想:选定Pivot中心轴大于Pivot的放到Pivot右边小于Pivot的放到Pivot左边分别对Pivot的左右子序列重复以上操作(直到序列长度为 1)阮一峰版本:https://www.cnblogs.com/hjx-blog/articles/9183453.html选取数组中间位置为 pivot,两个容器 left=[],right=[]。遍历数组,把小于 pivot 的放到 left 容器中;把大于 pivot 的放到 right 容器中哦。基线条件:当数组长原创 2022-03-06 17:02:03 · 653 阅读 · 0 评论 -
数组拍平五种方式(含基础内容回顾)
把多维数组转换为一维数组的方法:方法一:toString( )//答案:function flatten(arr) { return arr.toString().split(',').map(function(item){ return +item;//类型准换为 })}//解析:arr=[[1,2,3],[4,5,6],[7,8,9]]console.log(arr.toString());//输出 1,2,3,4,5,6,7,8,9console.log(arr.toS原创 2022-02-08 23:17:27 · 1046 阅读 · 0 评论