title: Difference between creating new instance by constructor and without constructor in javascript
body: <p>Formed an object 'myclass' in my js file like this:</p>
  
  <pre><code>var myclass = function(){
    this.m1 = function(){
      return "THis is m1 of myclass"
    };
    return "this is myclass";
  }
  myclass.prototype.mp1 = function(){
     return "this is mp1 of myclass"
  }
  </code></pre>
  
  <p>now i do this:</p>
  
  <pre><code>var a = new myclass();
  var b = new myclass;
  </code></pre>
  
  <p>Q1- I dont see any difference between the behaviors of these two. Please explain the reason.</p>
  
  <p>Q2 - When I do - console.log(a), i expect to get "this is myclass" in console, but instead I see [object object].</p>
  
  <p>Q3 - If I return an object from the constructor of 'myclass'(eg - return {x:1}), then I cannot use 'm1' or 'mp1' anymore from the instances of 'myclass'. </p>
  
  <p>Q4 - Comparing this with Date class of window object, this is totally different behavior. If a = new Date(), then i see value of 'a' as a date although the type is an object, and this points to my next question.</p>
  
  <p>Q5 - The date class returns a date which looks like a string in DOM but the 'typeof' of the instance of date class is an object. Why's that?</p>
  
  <p>Sorry for posting so many questions at once, but it would be nice if I get answers for all questions as I think they are related.</p>
  
  <p>This question is not about a particular question from the above 5. But combination of all. As I have to know the return type, comparison between myclass() and myclass, and comparison between myclass() and Date()/predefined window objects.  </p>