Search module in JavaScript I implemented search module, but I'm a novice in programming and I'm not sure about public and private functions that I coded. Did I do it right?

var data = require('./data');


function My_module(string) {
    var data_size_ = data.length;

    /**
     * @param {Array.&lt;Object&gt;} data.
     * @return {Array.&lt;Object&gt;} result.
     */

    var reformat_ = function() {
        var result = new Array(data_size_);

        var first_name;
        var last_name;
        var domain;

        for (var i = 0; i &lt; data_size_; ++i) {
            first_name = data[i].first_name.toLowerCase();
            last_name = data[i].last_name.toLowerCase();
            domain = data[i].domain.toLowerCase();

            result[i] = {
                'first_name': first_name,
                'last_name': last_name,
                'domain': domain,
            };
        }

        return result;
    };

    var formatted_data_ = reformat_();



    /**
     * A search function.
     * @return {Array.&lt;Object&gt;} Result
     */

    this.search = function(string) {
        var result = [];
        var len = string.length;

        for (var i = 0; i &lt; data_size_; ++i) {
            if (formatted_data_[i].first_name.slice(0, len) === string ||
                formatted_data_[i].last_name.slice(0, len) === string ||
                formatted_data_[i].domain.slice(0, len) === string) {
                result.push(formatted_data_[i]);
            }
        }

        if (result) {
            return result;
        }
    }

}


module.exports = My_module;
Rather than creating a function named My_module, and assigning it to module.exports, you can just directly assign a function to module.exports, like this:

module.exports = function() {
    ...
}


Secondly, why are you ending all your functions and variables in My_module with an underscore, _? It doesn't do anything, and if it's not serving a real naming purpose, it can be removed.