JSFiddle - React, Tailwind, and code Playground

by noblood

JavaScript

// * ON TEST JavaScript //
// Create private method that can not be called directly

function Container(param) {
    this.member = param;
    var that = this;
    
    // privileged method
    this.service = function () {
        return that.member;
    };
}

var myContainer = new Container('abc');

Container.prototype.stamp = function (string) {
   var stamp = this.member + string;
   alert(stamp);
}

myContainer.stamp('def');

alert(myContainer.service());

//http://javascript.crockford.com/private.html