PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, December 22, 2022

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

 December 22, 2022     function, javascript, object, syntax, typescript     No comments   

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)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

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

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing