Home » vue » What is the difference between equals "=" and colon ":" signs in Vue JS? [duplicate]

What is the difference between equals "=" and colon ":" signs in Vue JS? [duplicate]

Posted by: admin November 26, 2021 Leave a comment

Questions:

I have a onSubmit() method in Vuejs. Couldn’t figure what is the difference between equal = and colon : sign. Here is the following cod

methods:{
   onSubmit(){
     let product= {
     name: this.name,
     review: this.review,
     rating: this.rating
      },
    this.name=null,
    this.review=null,
    this.rating=null       
  }
}

In the above function I am storing values in object called product, after storing values I am assigning null values to data variables.

Why we are passing values to product object using : and to data object using = sign?

Answers:
{
     name: this.name,
     review: this.review,
     rating: this.rating
}

This creates an object, which is a data structure.

let product = {}

Here you are assigning the object (data structure) to a variable.