title: "push()" to an array in Typescript
body: <p>I have the following code, to scan for a Bluetooth device, which for every device found, I want to add the device to an array.</p>
  
  <pre><code>devices: Observable&lt;Array&lt;string&gt;&gt;;
  
  bluetoothAdd() {
      this.isScanning = true;
      var plusIcon = this.page.getViewById("add");
      plusIcon.style.opacity = 0;
  
      var self = this; 
      bluetooth.hasCoarseLocationPermission().then(
          function (granted) {
              if (!granted) {
                  bluetooth.requestCoarseLocationPermission();
              } else {
                  bluetooth.startScanning({
                      serviceUUIDs: ["133d"],
                      seconds: 4,
                      onDiscovered: function (peripheral) {
                          console.log("Periperhal found with UUID: " + peripheral.UUID);
                          this.devices.push(peripheral); // &lt;- Problem Line
                      }
                  }).then(function () {
                      console.log("scanning complete");
                      self.isScanning = false;
                      plusIcon.style.opacity = 1;
                  }, function (err) {
                      console.log("error while scanning: " + err);
                  });
                  this.isScanning = false;
              }
          });
  }
  </code></pre>
  
  <p>However, this code throws the following error:</p>
  
  <blockquote>
    <p>JavaScript error:
    file:///app/Pages/Home/home.component.js:99:37: JS ERROR TypeError: undefined is not an object (evaluating 'this.devices.push')</p>
  </blockquote>
  
  <p>I am working in Typescript, but I know the push function is a JS thing. Not sure how I would do this in Typescript - what have I done wrong?</p>