Using the prototype vs. using an object

Using angular.copy is expensive, should I use vanilla JS?

by Steven Senkus

JavaScript

var _matchCountStats = null,
    _matchCountStatsMaster = {
        hasLoadedInitialMatches: false,
        pageSize: 50, // this should be passed in as a parameter somewhere...

        totalExactMatches: 0,
        totalSimilarMatches: 0,

        exactPageCount: 0,
        similarPageCount: 0,
        totalPageCount: 0,

        searchId: null,

        addExact: function (numMatches) {
            this.totalExactMatches += numMatches;
            this.exactPageCount = this.roundPageCount(this.totalExactMatches);
        },
        addSimilar: function (numMatches) {
            this.totalSimilarMatches += numMatches;
            this.similarPageCount = this.roundPageCount(this.totalSimilarMatches);
        },
        roundPageCount: function (val) {
            return Math.ceil(val / _matchCountStats.pageSize);
        },
        getTotalPageCount: function () {
            this.totalPageCount = this.exactPageCount + this.similarPageCount;
            return this.totalPageCount;
        },
        getLabel: function () {
            var label = this.getTotalPageCount() + ' T,' + this.exactPageCount + ' E,' + this.similarPageCount + ' S';
            return label;
        }
    };



function matchCounter() {

    this.hasLoadedInitialMatches = false,
    this.pageSize = 50, // this should be passed in as a parameter somewhere...

    this.totalExactMatches = 0;
    this.totalSimilarMatches = 0;

    this.exactPageCount = 0;
    this.similarPageCount = 0;
    this.totalPageCount = 0;

    this.searchId = null;

}

matchCounter.prototype.addExact = function (numMatches) {
    this.totalExactMatches += numMatches;
    this.exactPageCount = this.roundPageCount(this.totalExactMatches);
},
matchCounter.prototype.addSimilar = function (numMatches) {
    this.totalSimilarMatches += numMatches;
    this.similarPageCount = this.roundPageCount(this.totalSimilarMatches);
},
matchCounter.prototype.roundPageCount = function (val) {
    return Math.ceil(val...