Problem with displaying proto properties

This is my first time posting on the forum.

I am having a strange problem which I would like some help with or clarification.

I am using Visual Studio Code to practice my FCC problems, however whenever
I execute the code for this specific exercise I’m getting erratic output.

After creating the instance of my Dog constructor, I display it using the console.log
method just to verify it. I then move on to display the ownProps and prototypeProps
arrays.

However, whenever I console.log the beagle instance, I only get the output for
ownProps array. ‘console.log(prototypeProps)’ is mysteriously omitted.
If I remove the console.log(beagle), both arrays are outputted correctly.

Can anybody explain this behaviour, or is it possibly an issue with Visual Studio Code?
FCC seems to be logging the info correctly.

Your code so far


function Dog(name) {
this.name = name;
}

Dog.prototype.numLegs = 4;

let beagle = new Dog("Snoopy");
console.log(beagle);

let ownProps = [];
let prototypeProps = [];

// Only change code below this line
for (let property in beagle) {
  if (Dog.hasOwnProperty(property)) {
    ownProps.push(property);
  } else {
    prototypeProps.push(property);
  }
}
console.log(ownProps);
console.log(prototypeProps);

**Your browser information:**

User Agent is: <code>Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.89 Safari/537.36</code>.

**Challenge:** Iterate Over All Properties

**Link to the challenge:**
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/object-oriented-programming/iterate-over-all-properties

VS Code cannot execute this code by itself, do you mean you run it in the Node?

That would be correct

I run the code without debugging (ctrl + F5) and select Node.js (preview), not sure if this is the correct way to go about executing Javascript code, has worked for the basic code snippets that I have worked with up until this point.

I checked it with visual studio code and the output is as expected with and without console.log(beagle). this is the output I get:

Dog { name: 'Snoopy' }
[ 'name' ]   
[ 'numLegs' ]

are you commenting it out or deleting the line. either way, make sure you’re not applying that change to other lines.

Here is the code and its output

My guess would be that it has to do something with how debugger works in VS Code and I’m not sure this is correct way of using debugger. Normally you would want to use breakpoints instead of console.log in debugger.