Home > Software design >  When to use : and = in javascript?
When to use : and = in javascript?

Time:01-27

I have these code snippet.

 const initialAuthState = {
  isAuthenticated:false
};

and

function login(state){
      state.isAuthenticated=true;
    }

How do I know when to use '=' and when to use ':' in javascript?

CodePudding user response:

= inside a function or code block (like inside an if/else/for/while etc.), : inside of objects.

  •  Tags:  
  • Related