Question

Q1: Describe the difference between the equality operator (==) and the identity operator (===). Use if...

Q1: Describe the difference between the equality operator (==) and the identity operator (===). Use if statements to demonstrate your understanding.

Q2: How can you tell the difference between the number 3 and the string 3 in variable assignment?

All the questions from basic JavaScript.

Thanks!

0 0
Add a comment Improve this question Transcribed image text
Answer #1

/*If you have any query do comment in the comment section else like the solution*/

Ans1:

<!DOCTYPE html>
<html>
<body>
<script>
   function isEqual() {
var x = 3;
var y = "3";
if(x==y){
alert("Equal");
}
else
alert("Not Equal");
}

function isIdentical() {
var x = 3;
var y = "3";
if(x===y){
alert("Identical");
}
else
alert("Not Identical");
}
</script>
<button type="submit" onclick="isEqual();">isEqual</button>
<button type="submit" onclick="isIdentical();">isIdentical</button>
</body>
</html>

var x=3 // implies assignment of integer 3 to variable x

var y= "3" implies assignment of string 3 to variable y

Hence difference can be identified by the double quotes.

Add a comment
Know the answer?
Add Answer to:
Q1: Describe the difference between the equality operator (==) and the identity operator (===). Use if...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT