Skip to content

Commit af60f47

Browse files
authored
Update Map.for_each docs (#2266)
* Update Map.for_each docs * edit text
1 parent b1daf81 commit af60f47

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

crates/js-sys/src/lib.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1300,7 +1300,14 @@ extern "C" {
13001300

13011301
/// The `forEach()` method executes a provided function once per each
13021302
/// key/value pair in the Map object, in insertion order.
1303-
///
1303+
/// Note that in Javascript land the `Key` and `Value` are reversed compared to normal expectations:
1304+
/// # Examples
1305+
/// ```
1306+
/// let js_map = Map::new();
1307+
/// js_map.for_each(&mut |value, key| {
1308+
/// // Do something here...
1309+
/// })
1310+
/// ```
13041311
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/forEach)
13051312
#[wasm_bindgen(method, js_name = forEach)]
13061313
pub fn for_each(this: &Map, callback: &mut dyn FnMut(JsValue, JsValue));

0 commit comments

Comments
 (0)