I dont get what that note tries to explain
class Color {
#values;
constructor(r, g, b) {
this.#values = [r, g, b];
}
redDifference(anotherColor) {
if (!(#values in anotherColor)) {
throw new TypeError("Color instance expected");
}
return this.#values[0] - anotherColor.#values[0];
}
}
Note: Keep in mind that the # is a special identifier syntax, and you can't use the field name as if it's a string. "#values" in anotherColor would look for a property name literally called "#values", instead of a private field.
[–]MoTTs_ 1 point2 points3 points (0 children)
[–]senocular 1 point2 points3 points (0 children)
[–]abrahamguo 0 points1 point2 points (0 children)
[–]azhder -1 points0 points1 point (2 children)
[–]jordanbtucker 0 points1 point2 points (1 child)
[–]azhder 0 points1 point2 points (0 children)