I'm trying to make a module wich have properties and functions, that can be used like a validator object that valid all the objects inside, with a valid method that return true if validator success.

so i make this file

```
function Machine(params)
{
    // this is the constructor
    if(params){
        var pub=params;
        return this.init(pub);
    }
    this.obj_params = 'null';
    this.valid = 'Not Valid';
};
Publicacion.prototype.init = function(objConfig){
    console.info('Init Success!')
    this.buildMachine(objConfig);

    return true
};
Publicacion.prototype.buildPublish = function(objConfig){
    console.info('Builded!');
    //this.valid='success'; // when uncommited, the object this.valid appears

    return true;
};

module.exports=Machine;

```

and this is the console

```
> var Machine=require('./Machine')
> undefined
> var machinegun=new Machine();
> Init Success!
> Builded!
> undefined
> machinegun.valid
> undefined

```

two problems:

1. When i try to access to "machinegun.valid" this returns me a undefined
2. When i use the build method to define valid, the var valid appears.

why the constructor did not define the valid variable at first??
why valid variable can be defined by the build method???

i dont understand how javascript works with classes... 

thnx all!