找出缓存 Symbol 里的 bug

来自 Symbol
Node 24 入门 4分钟 找出 1处问题

找出 readCache 为什么始终读不到 writeCache 写入的值。

JavaScript
const cacheKey = Symbol('cache');

function writeCache(record, value) {
  record[cacheKey] = value;
}

function readCache(record) {
  return record[Symbol('cache')];
}

const order = {};
writeCache(order, 7);
console.log(readCache(order));
在试验场中打开
报告错误