如何从控制台 chrome 复制地图对象?

问题描述

我想从 chrome 控制台复制以角度创建的地图:

Map(7) {1 => {…},2 => {…},3 => {…},4 => {…},5 => {…},…}

我无法完整复制这张地图!

解决方法

我假设您要复制地图条目,您可以使用 chrome 的 copy 命令。

// create large amount of entries as an example
const entries = Array(100).fill(null).map((_,i) => [i,i]);

const map = new Map(entries);

// this would copy the map's entries to clipboard
copy(Array.from(map));