In javascript, Can we define a datamembers/any datastucture without declaring them outside constructor
Like this :
class Queue {
constructor() {
this.items = [];
}
}
>Solution :
Yes, we can define data members inside the constructor without declaring them outside. In the example above, the data member "items" is declared inside the constructor without being declared outside.