Comprende los peligros de usar el código imperativo

const Window = function (tabs) {

            this.tabs = tabs;

        };

        Window.prototype.join = function (otherWindow) {

            this.tabs = this.tabs.concat(otherWindow.tabs);

            return this;

        };

        Window.prototype.tabOpen = function (tab) {

            this.tabs.push('new tab');

            return this;

        };

        Window.prototype.tabClose = function (index) {

            /*  console.log(this.tabs)// ==> ['Netflix', 'YouTube', 'Vimeo', 'TikTok'] */

            /*  console.log(this.tabs)// ==> ['GMail', 'Inbox', 'Work mail', 'Docs', 'freeCodeCamp'] */

            const tabsBeforeIndex = this.tabs.splice(0, index); // ==> ['Netflix', 'YouTube']  / ==> ['GMail']    ===> " lo que se extrajo del array"

            console.log(tabsBeforeIndex)// ==> ['Netflix', 'YouTube'] / ==> ['GMail']   ===> " lo que se extrajo del array"

            console.log(this.tabs)// ==>['Vimeo', 'TikTok']  / ==> ['Inbox', 'Work mail', 'Docs', 'freeCodeCamp']  ===>  "  array resultante de lo que quedo en el array original "

            const tabsAfterIndex = this.tabs.splice(1); // ['TikTok']  / ['Work mail', 'Docs', 'freeCodeCamp'] ===> " lo que se volvio a  extraer  del array"

            console.log(tabsAfterIndex) // ['Vimeo']  /  ['Work mail', 'Docs', 'freeCodeCamp']  ===> " lo que se volvio a  extraer  del array"

            console.log(this.tabs) // ['Vimeo']  /  ['Inbox']  ===>  " array resultante de lo que quedo en el array original "

            this.tabs = tabsBeforeIndex.concat(tabsAfterIndex); // ==> ['Netflix', 'YouTube'] + ['TikTok']  =  ['Netflix', 'YouTube','TikTok' ] /   ==> ['GMail']  +  ['Work mail', 'Docs', 'freeCodeCamp'] =  ['GMail','Work mail', 'Docs', 'freeCodeCamp']

            return this;

        };

        const workWindow = new Window(['GMail', 'Inbox', 'Work mail', 'Docs', 'freeCodeCamp']);

        const socialWindow = new Window(['FB', 'Gitter', 'Reddit', 'Twitter', 'Medium']);

        const videoWindow = new Window(['Netflix', 'YouTube', 'Vimeo', 'TikTok']);

        const finalTabs = socialWindow.tabOpen().join(videoWindow.tabClose(2)).join(workWindow.tabClose(1).tabOpen());

        // const finalTabs = videoWindow.tabClose(1); // ==> ['Netflix']

        // const finalTabs = videoWindow.tabClose(-1);// ==> ['Netflix', 'YouTube', 'Vimeo']

        // const finalTabs = videoWindow.tabClose(4);// ==> ['Netflix', 'YouTube', 'Vimeo', 'TikTok']

        // const finalTabs = videoWindow.tabClose(2);

        //const finalTabs = workWindow.tabClose(1);

        console.log(finalTabs.tabs);

Can you tell us more about what you are asking? The more you tell us, the more we can help.

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).