Thursday, December 22, 2022

[FIXED] When to use : and = in javascript?

Issue

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?


Solution

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



Answered By - Samathingamajig
Answer Checked By - Gilberto Lyons (PHPFixing Admin)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.