Why "this.tabs" is an array?

Hello,
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/functional-programming/understand-the-hazards-of-using-imperative-code

Why in this case, “this.tabs” is an array ?

var Window = function(tabs) {
  this.tabs = tabs; // We keep a record of the array inside the object
};

I would have written:

var Window = function(tabs) {
  this.tabs = [];
};

if it’s an empty array you can’t have a reference to the array passed in to the function
it’s an array because the function parameter is an array

look at when Windows is used: it has an array as argument

// Let's create three browser windows
var workWindow = new Window(['GMail', 'Inbox', 'Work mail', 'Docs', 'freeCodeCamp']); // Your mailbox, drive, and other work sites
var socialWindow = new Window(['FB', 'Gitter', 'Reddit', 'Twitter', 'Medium']); // Social sites
var videoWindow = new Window(['Netflix', 'YouTube', 'Vimeo', 'Vine']); // Entertainment sites

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.