Feb 28, 2025
Please rework the section which falsely claims that privacy can be achieved through Symbols
, and that the latter can be used as well for hiding critical informations securely. It's a dangerous advice and/or misbelieve. Object.getOwnPropertySymbols
already is all what it needs in order to unveil everything ...
const secretKey = Symbol("hiddenValue");
const secureObject = {
[secretKey]: "Top Secret Info",
publicData: "Visible to Everyone"
};
function getThisValue(key) {
return this[key];
}
console.log(
Object
.getOwnPropertySymbols(secureObject)
.map(getThisValue, secureObject)
);
And Object.getOwnPropertyDescriptors
will always provide everything about an object’s structure.
const secretKey = Symbol("hiddenValue");
const secureObject = {
[secretKey]: "Top Secret Info",
publicData: "Visible to Everyone"
};
console.log(
Object
.getOwnPropertyDescriptors(secureObject)
);