Hello,
While I am working on this project:
(https://www.codecademy.com/journeys/front-end-engineer/paths/fecj-22-front-end-development/tracks/fecj-22-javascript-syntax-part-iii/modules/wdcp-22-find-your-hat-10850a06-4cc1-43f0-95d4-6d824fd91120/projects/find-your-hat),
I wanted t make a distinction between class attributes and instance attributes, like in Python, for example:
Python:
class Field:
hat = '^'
hole = 'O'
fieldCharacter = '░'
pathCharacter = '*'
def __init__(self):
self.field = []
self.boundarieX = 0
self.boundarieY = 0
self.positionX = 0
self.positionY = 0
So, in JS I did:
class Field {
hat = '^';
hole = 'O';
fieldCharacter = '░';
pathCharacter = '*';
constructor() {
this.field = [];
this.boundarieX = 0;
this.boundarieY = 0;
this.positionX = 0;
this.positionY = 0;
}
}
But, if I try to access to attributes who are not declared in the constructor, I can.
Is there a way in JS to “isolate” attributes only for the class?