How do prototypes in js add functions?

currently encapsulated table plug-ins are as follows:

(function ($) {

    function Table() {

        this.config = {
           //
        }

    };

    Table.prototype = {
       //table
        rend: function (config) {

            return this;
        }
    };

    window.Table = Table;

}(jQuery));

plugin call method:

var abc = new Table();
abc.rend({
    ele:"-sharptable1"
});

question: there are some functions that belong to rend customization that I want to write into HyTable.prototype "s rend, but will this result in a closure? Will it cause a memory leak if there are too many functions defined? Or is there a better way?

Mar.23,2021

1. Closures will not be generated. Specifically, you can see the definition of closures
2. Memory leaks are related to whether the data has been released. If you just use it up and do not reference it elsewhere, it will not cause memory leaks
3. If you want to define a lot of functions, put them in rend, which will affect the readability of the code. You can define functions on Table.prototype


.

there is no problem at all, and it is often necessary to define methods within a method that can only be used within that method, even if only for the readability of the code.

Table.prototype = {
    render:function(config){
        function a(){}
        
        function b(){}
        
        ......
    }

}

Table.prototype.addFunc = function(){}

write complete OK in this way

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b37f69-34486.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b37f69-34486.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?