Jump to content

comparing 2 variable values


Destramic
 Share

Recommended Posts

I'm confused what you mean by "comparing" two variables since that's what you did yourself in the main post. Also you should use tripple '=' operator, not double, if you want to be sure the two values are actually the same, because then it makes sure the type of the variable is the same as well. For instance a string of "1" and an integer of 1 would be "the same" when using double '=' operator.

 

Example:

 

 

var first = "1";
var second = 1;
 
console.log(first == second); //true
console.log(first === second); //false, different types.

 

But could you please elaborate more what you mean by "comparing" two variables ? Because like I said, it looks like you did it yourself in the main post.

Link to comment
Share on other sites

This thread is more than a year old. Are you sure you have something important to add to it?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.