title: AngularJS : What is a factory?
body: <p>I've been doing a lot of work on <code>Angular.js</code> and overall I find it to be an interesting and powerful framework.</p>
  <p>I know there have been a lot of discussions on Services vs. Factories vs. Providers vs. Values, but I am still pretty confused about what a <code>Factory</code> is.</p>
  <p>Factory has been defined in other StackOverflow discussions as the following:</p>
  <p><em>Factories</em></p>
  <p>Syntax: <code>module.factory( 'factoryName', function );</code> Result: When declaring factoryName as an injectable argument you will be provided with the value that is returned by invoking the function reference passed to module.factory.</p>
  <p>I find this explanation to be very difficult to grasp and it doesn't increase my understanding of what a factory is.</p>
  <p>Would anyone have any explanations or real life examples to share about what exactly a <code>Factory</code> is and why you should use it in lieu of a <code>Service</code>, <code>Provider</code>, or other?</p>
  <h3>Update</h3>
  <p>A <code>service</code> <em>holds a reference</em> to any <strong>object</strong>.</p>
  <p>A <code>factory</code> <em>is a function</em> which returns any <strong>object</strong></p>
  <p>A <code>provider</code> <em>is a function</em> which returns any <strong>function</strong></p>
  <p>-<em>phew</em>-</p>