hey guys i was just going through the code of tabs.js and i came across the following lines of code :
if (!data) $this.data('bs.tab', (data = new Tab(this)))
if (typeof option == 'string') data[option]()
now i have a question abot the above 2 lines of code , Why is the new keyword being used ? why could't the Tab()
function be called directly , like so :
Tab[option]()
instead of data[option]()
?
this coding convention of adding the new keyword is common to all bootstrap plugins , i just want to know why , i am not asking what the new keywords does , i am just asking , why is it being used in this scenario ? I have read this thread here on the new keyword.
but my question really is :
Why is the new keyword being used ? why could't the Tab()
function be called directly ?