title: Sending data to firebase: data.push() is not a function
body: <p>I am trying to send data to firebase using html and Jquery. Here is my code:-</p>
  
  <pre><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script src="https://cdn.firebase.com/js/client/2.2.0/firebase.js"&gt;&lt;/script&gt;
  &lt;!--&lt;script src="https://www.gstatic.com/firebasejs/4.11.0/firebase.js"&gt;&lt;/script&gt;--&gt;
  &lt;script&gt;
    // Initialize Firebase
      var config = {
          apiKey: "demoAPIkey",
          authDomain: "demoAuthDomain",
          databaseURL: "demoDBurl",
          projectId: "demoProjectID",
          storageBucket: "demo.appspot.com",
          messagingSenderId: "demoSendingID"
      };
      firebase.initializeApp(config);
  &lt;/script&gt;
  &lt;script&gt;
      $(function(){
          //make a variable to keep track of data coming from firebase
          var data= [];
  
          //create new connection to firebase
          var ref= new Firebase('http://demoDBurl/food');
  
          //listen to data updates from firebase
          ref.on("value", function (snapshot){
              console.log(snapshot.val());
              //when the data updates at firebase, put it in the data variable
              data= snapshot.val();
          })
  
          //Entire Form (handler)
          $('#saveFoodForm').on('click',function(event) {
  
              event.preventDefault();
              var $form = $(this);
              console.log("Submit to Firebase");
  
              //disable submit button
              $form.find("#saveForm").prop('disabled', true);
  
              //get values to send to Firebase
              var titleToSend = $('#foodTitle').val();
              console.log(titleToSend);
  
              var descriptionToSend = $('#foodDescription').val();
              console.log(descriptionToSend);
  
              var categoryToSend= $('#foodCategory').val();
              console.log(categoryToSend);
  
              //take the values from the form, and put them in an object
              var newFood = {
                  "description": descriptionToSend,
                  "title": titleToSend,
                  "type": categoryToSend
              };
  
              //put new object in data array
              data.push(newFood);
              //send the new data to Firebase
              ref.set(data, function(err){
                  if(err)
                  {
                      alert(err);
                  }
              });
  
              return false;
          });
      })
  &lt;/script&gt;
  </code></pre>
  
  <p>I am getting an error: </p>
  
  <pre><code>Uncaught TypeError: data.push is not a function
      at HTMLInputElement.&lt;anonymous&gt; (index.html:61)
      at HTMLInputElement.dispatch (jquery.min.js:2)
      at HTMLInputElement.y.handle (jquery.min.js:2)
  </code></pre>
  
  <p>How can I solve it?</p>