CopyPastor

Detecting plagiarism made easy.

Score: 1; Reported for: String similarity Open both answers

Possible Plagiarism

Plagiarized on 2018-03-29
by Suseendran Kandasamy

Original Post

Original - Posted on 2008-11-05
by guinaps



            
Present in both answers; Present only in the new answer; Present only in the old answer;

Do: ===
var isTrueSet = (myValue == 'true');
---
Unnecessary: ---

You could make it stricter by using the identity operator (`===`), which doesn't make any implicit type conversions when the compared variables have different types, instead of the equality operator (`==`), which does:
var isTrueSet = (myValue === 'true');
---
Don't: ---
You should probably **be cautious about using these two methods** for your specific needs:
var myBool = Boolean("false"); // == true
var myBool = !!"false"; // == true
Any string which isn't the empty string will evaluate to `true` by using them. Although they're the cleanest methods I can think of concerning to boolean conversion, I think they're not what you're looking for.
Do: ===
var isTrueSet = (myValue == 'true');
---
Unnecessary: ---

You could make it stricter by using the identity operator (`===`), which doesn't make any implicit type conversions when the compared variables have different types, instead of the equality operator (`==`), which does:
var isTrueSet = (myValue === 'true');
---
Don't: ---
You should probably **be cautious about using these two methods** for your specific needs:
var myBool = Boolean("false"); // == true
var myBool = !!"false"; // == true
Any string which isn't the empty string will evaluate to `true` by using them. Although they're the cleanest methods I can think of concerning to boolean conversion, I think they're not what you're looking for.

        
Present in both answers; Present only in the new answer; Present only in the old answer;