Forum Discussion

Vec84's avatar
Vec84
Contributor
8 years ago

Using Properties instead of Params

Our AUT currently runs through a flow of forms and i have a Unit for each form which i consider to be a class and each form has multiple outcomes and each form has multiple functions. I have added pa...
  • tristaanogre's avatar
    tristaanogre
    8 years ago

    Yes.  Basically, whatever function you'd determine to be your constructor would assign all your properties.  It would look like:

     

    function constructorA() {
        var localObject = {prop1: '', prop2: 0} //Sets up the object with properties and default values
    
        localObject.Method1 = function () {
            Log.Message('Valjean 1: ' + localObject.prop1);
        }
        localObject.Method2 = function () {
            Log.Message('Marius: ' + localObject.prop2);
        }
        return localObject;
    }
    
    function Main() {
        var myObject = new constructorA();
        myObject.prop1 = 'Who am I?"
        myObject.prop2 = 24601;
        myObject.Method1();
        myObject.Method2();
        
    }