-
Notifications
You must be signed in to change notification settings - Fork 3
Array 对象方法整理 #5
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Labels
Comments
数组的深拷贝
参考: |
数组去重
|
排序数据按中文拼音首字母排序
表格实现正序反序
|
|
数组求最大最小值
|
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
数组创建与修改
1. 创建
//创建一个新数组实例
//将类数组(类似数组的对象和可遍历的对象)转为真正的数组。
2. 合并
//合并两个或多个数组。不更改现有数组,而是返回一个新数组。
3. 转化为字符串
//以separator(默认为逗号)拼接为字符串。
//把数组转换为字符串,数组中的元素之间用逗号分隔。
4. 填充
//用一个固定值填充[start,end)的元素。
判断数组
//判断传递的值是否是一个 Array。
筛选排序递归
1. 筛选
2. 排序
//将数组中元素的位置颠倒。
3. 递归
增删改查
1. 查找
//执行一次 callback 函数,直到找到一个使得 callback 返回true。
//数组的所有元素是否都通过callback 函数。
//在数组中返回符合callback第一个元素的值。
//返回数组中满足callback的第一个元素的索引。否则返回-1。
//是否包含一个指定的值
2. 增、删
//删除数组最后一个元素,并返回该元素的值。
//增加元素到数组末尾。
//删除数组第一个元素。
//增加元素到数组开头。
//返回[start,end)**浅拷贝**到一个新数组对象,**原数组不会被修改**。
//通过删除现有元素和/或添加新元素来更改一个数组的内容,**会直接对数组进行修改**。
循环遍历
//返回一个新的Array Iterator对象,该对象包含数组中每个索引的键/值对。
//返回一个新的Array迭代器,它包含数组中每个索引的键。
//返回一个新的 Array Iterator 对象,该对象包含数组每个索引的值。
实用方法:
将参数转化为数组
var _arguments=Array.prototype.slice.apply(arguments)
参考文档
The text was updated successfully, but these errors were encountered: