urlSearchParams.forEach(fn[, thisArg])
fn
<Function> 为查询中的每个名称-值对调用thisArg
<Object> 在调用fn
时用作this
值
迭代查询中的每个名称-值对并调用给定的函数。
const myURL = new URL('https://example.org/?a=b&c=d');
myURL.searchParams.forEach((value, name, searchParams) => {
console.log(name, value, myURL.searchParams === searchParams);
});
// 打印:
// a b true
// c d true
fn
<Function> Invoked for each name-value pair in the querythisArg
<Object> To be used asthis
value for whenfn
is called
Iterates over each name-value pair in the query and invokes the given function.
const myURL = new URL('https://example.org/?a=b&c=d');
myURL.searchParams.forEach((value, name, searchParams) => {
console.log(name, value, myURL.searchParams === searchParams);
});
// Prints:
// a b true
// c d true