JSFiddle - React, Tailwind, and code Playground

JavaScript

var IsValid = function () {
     return this.trim().length > 0;
}

var method = function () {
     var modelState = new String("My model");
    Object.defineProperty( modelState, "IsValid", {
      get: function() { return IsValid; },
      enumerable: false,
      configurable: false
    });
    return modelState.IsValid()
}

console.log( method() );