title: Fabricjs count objects
body: <p>Is there any way to count how many objects are already in canvas using Fabric.js</p>
  
  <pre><code>    function addImage(imageName) {
  
      fabric.Image.fromURL('./image_path/' + imageName, function (image) {
  
          image.set({
              left: 10,
              top: 10,
              width: 100,
              height: 100,
              centeredScaling: true,
              lockUniScaling: true
          })
  
  
          canvas.add(image);
      });
  };
  </code></pre>
  
  <p>and then you have jQuery:</p>
  
  <pre><code>    $('.click').on("click", function (e) {
      e.preventDefault;
      var imgId = $(this).attr('id');
  
      var number = $('canvas img').length;
      if (number == 5) {
          alert("You can add only 5 images");
      } else {
          addImage(imgId + ".png");
      }
  });
  </code></pre>
  
  <p>Is there any way to count it?</p>