I faced a strange problem in my Node.js project. I have a class and need to hide some of his methods. MDN says that i need to put #
at the beginning of the method name. And this is not valid. I have 13.6 Node version: Here's my code:
module.exports.class = class ExtendedEmbed extends MessageEmbed {
static #validateColors(colors) {
// Do something;
}
static #validateTemplates() {
// Do something...
}
// Other methods...
/**
* @param {String} color
* @param {String} template
* @param {import('discord.js').MessageEmbedOptions} data
* @param {import('./index').ExtendedEmbedOptions} options
*/
constructor(color, template, data = {}, options = {}) {
console.log(ExtendedEmbed.#validateColors(options.colors);
}
}
Here's the error:
C:\Projects\EmbedUtilities\src\ExtendedEmbed.js:4
static #validateColors(colors) {
^
SyntaxError: Unexpected token '('
What about using a private method instead of the static once?
private validateTemplates() {
// Do something...
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.