Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

第 37 题:编程题1 #54

Open
ravencrown opened this issue Aug 23, 2019 · 0 comments
Open

第 37 题:编程题1 #54

ravencrown opened this issue Aug 23, 2019 · 0 comments

Comments

@ravencrown
Copy link
Owner

ravencrown commented Aug 23, 2019

1. 数组快速删除一个已知元素

arr = arr.filter(item => {
  return item != aitem
})

2. 查找URL的参数,getUrlParam

// 解法一
function getUrlParam (name, url) {
    // 参数:变量名,url为空则表从当前页面的url中取
    var u = arguments[1] || window.location.search;
    var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
    var r = u.substr(u.indexOf('?') + 1).match(reg);
    return r != null ? r[2] : '';
}

// 解法二
function getUrlParam(name){
   let query = window.location.search.substring(1);
   let vars = query.split("&");
   for (let i=0;i<vars.length;i++) {
     let pair = vars[i].split("=");
     if(pair[0] == name){
       return pair[1];
     }
   }
  return(false);
}

3. 深拷贝

5. 数组拍平

6. 数组乱序

7. 查找数组最大

8. 查找数组最小

9. 数组去重

10. 数组删除一个子数组

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant