| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Map/forEach | [Back] [Original] |
Get to know MDN better
function logMapElements(value, key, map) {
console.log(`m[${key}] = ${value}`);
}
new Map([
["foo", 3],
["bar", {}],
["baz", undefined],
]).forEach(logMapElements);
// Expected output: "m[foo] = 3"
// Expected output: "m[bar] = [object Object]"
// Expected output: "m[baz] = undefined"
forEach(callbackFn)
forEach(callbackFn, thisArg)
callbackFnmap
thisArg callbackFn this
forEach map callback undefined
callbackFn
valuekeyMap forEach thisArg callback this undefined this callback this this
forEach callback forEach
Map
function logMapElements(value, key, map) {
console.log(`map.get('${key}') = ${value}`);
}
new Map([
["foo", 3],
["bar", {}],
["baz", undefined],
]).forEach(logMapElements);
//
// "map.get('foo') = 3"
// "map.get('bar') = [object Object]"
// "map.get('baz') = undefined"
| ECMAScript 2027 LanguageSpecification # sec-map.prototype.foreach |
MapObject/FunctionObject.prototype.__defineGetter__()Object.prototype.__defineSetter__()Object.prototype.__lookupGetter__()Object.prototype.__lookupSetter__()Object.prototype.hasOwnProperty()Object.prototype.isPrototypeOf()Object.prototype.propertyIsEnumerable()Object.prototype.toLocaleString()Object.prototype.toString()Object.prototype.valueOf()| Web Proxy Viewer | New URL | Original Page |