1. 獲取 url 的參數
function getParameter(parName){
var str = parName.toLowerCase() + "=";
var gvalue = "";
var HREF = location.href;
var upperHREF = location.href.toLowerCase();
if(upperHREF.indexOf(str)>0){
gvalue = HREF.substring(upperHREF.indexOf(str) + str.length,upperHREF.length);
if(gvalue.indexOf('&')>0) gvalue = gvalue.substring(0,gvalue.indexOf('&'));
if(gvalue.indexOf("#")>0) gvalue = gvalue.split("#")[0];
}
return gvalue;
}
?
2. 數組對象 根據條件過濾
(1). 獲取年齡 18 的數據
let array = [{id:1,name:"靚仔",age:18},{id:2,name:"靚女",age:18},{id:3,name:"瘦子",age:16},{id:4,name:"肥仔",age:28}]
? function filterAge (array=[]){
let array = [{id:1,name:"靚仔",age:18},{id:2,name:"靚女",age:18},{id:3,name:"瘦子",age:16},{id:4,name:"肥仔",age:28}]
? function filterId (array=[]){
本文摘自 :https://www.cnblogs.com/