urlSearchParams.forEach(fn[, thisArg])


版本历史
版本变更
v18.0.0

将无效回调传给 fn 参数现在会抛出 ERR_INVALID_ARG_TYPE 而不是 ERR_INVALID_CALLBACK

  • fn <Function> 为查询中的每个名称-值对调用

    \fn <Function> Invoked for each name-value pair in the query

  • thisArg <Object> 在调用 fn 时用作 this

    \thisArg <Object> To be used as this value for when fn 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 

AltStyle によって変換されたページ (->オリジナル) /