Question about assignment in constructors

This is more of a general query about colons and assignment operators (equal signs)
Within objects, I’ve seen colons and equal signs used to assign properties. I feel like the appropriate use of an equal sign is at the beginning of the object (i.e. function Dog() = {) and a colon is to indicate the value of a property.

Would someone mind clarifying this rule?

Thanks as always
Nick
Tell us what’s happening:
Describe your issue in detail here.

  **Your code so far**

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

// Only change code below this line
Dog.prototype = {

numLegs: 4,
eat: function() {
  console.log("nom nom nom");
},
describe: function() {
  console.log("My name is " + this.name);
}
};
  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36

Challenge: Remember to Set the Constructor Property when Changing the Prototype

Link to the challenge:

When you are declaring an object, you use a colon to separate the name and the value.
Like this

const arielleslie = {
    isAwesome: true,
    daysSinceLastTypo: 1
};

But outside of the declaration, you can still set object properties. You could be adding a property or changing the value of one. For that you use the assignment operator.
Like this

arielleslie.daysSinceLastTypo = 0; // Oops

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.