Edit Fork Copy function MVC(){ this.mysql= require('mysql'); this.host=''; this.user=''; this.password=''; this.connected = function(host, user, password){ this.host=host; this.user=user; this.password=password; this.conn=this.mysql.createConnection(this.host,this.user,this.password); this.conn.connect(function(err){ if(err) throw err; console.log('Connected'); }) } }; var demo= new MVC(); demo.connected("localhost","root","");