title: ECS6 How define/create new an Object inside a Class
body: <p>I'm beginner in em ES6, and I need instantiate new objects inside a class. 
  How the best way to make this, and how I can access "in this case" the connection in the function getName(). </p>
  
  <p>Probably talking nonsense, but I need to understand how this works to evolve. Anyone would have any tips for me.</p>
  
  <p>above little exemple</p>
  
  <pre><code>class Test {
    constructor(array){
      this.array = array
  
      // CONNECT DATABASE
      var connection = mysql.createConnection({this.array})
  
    }
    getName(){
      query = 'SELECT * FROM mytable LIMIT 1'
      connection.query(query, function (err, rows, fields) {
        return rows
      })
    }
  }
  
  
  array = {
    host: 'localhost',
    user: 'root',
    password: '',
    database: 'mydb'
  }
  
  let T = new Test(array)
  
  T.getName()
  // error connection is not defined
  </code></pre>