We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
class Map { constructor() { this.$keyObj = {}; this.$valueObj = {}; this.$length = 0; } set(key, value) { const autoKey = `key${Map.idx++}`; this.$keyObj[autoKey] = key; this.$valueObj[autoKey] = value; // 需要判断是否覆盖来控制 $length } _getAutoKey(key) { const keyItem = Object.entries(this.$keyObj).find(x => x[1] === key); return keyItem[0]; } get(key) { const autoKey = this._getAutoKey(key); if (!autoKey) { return undefined; } return this.$valueObj[autoKey]; } } Map.idx = 1; // Usage var map = new Map(); var key = new Object(); map.set(key, 1); console.log(map.get(key), map.get(key) === 1);
The text was updated successfully, but these errors were encountered:
No branches or pull requests
The text was updated successfully, but these errors were encountered: