While I was going through JavaScript functions, I've came across following code which works fine
var Dog = function(name, breed) {
   this.name = name;
   this.breed = breed;
   console.log(this.name);
};
var firstDog = new Dog("munni","doberman");
Then I try to play around it and got stuck with this code
var Dog = function(name, breed) {
   var name = name;
   var breed = breed;
   console.log(this.name);
};
var firstDog = new Dog("munni","doberman");
In this code when I remove this, It works fine. I understood that this points to the current object. But I'm not able to figure it out what's going on here. Should I always use this operator while initializing properties in constructors? I just want to know best practice for this since I'm a beginner. Any helpful answer will be appreciated.
 
     
    