Skip to content

Instantly share code, notes, and snippets.

Created Oct 7, 2015
Embed
What would you like to do?
JS Bin // source https://jsbin.com/bunoje
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
var testStr = function () {
var a = "5";
var b = "44";
return a > b; // true, lex comparison
};
console.log("num str", testStr());
var testArray = function () {
var a = [1];
var b = [1];
return a == b; // false, obj references
};
console.log('arrays', testArray());
var testEmpty = function () {
var a = 0;
var b = []; //""
return a == b; // true, both coerced to num when either is num
};
console.log('empty things', testEmpty());
var testEmpty = function () {
var a = "";
var b = false;
return a == b; // true, both coerced to bool when both bool
};
console.log('bools', testEmpty());
</script>
<script id="jsbin-source-javascript" type="text/javascript">var testStr = function () {
var a = "5";
var b = "44";
return a > b; // true, lex comparison
};
console.log("num str", testStr());
var testArray = function () {
var a = [1];
var b = [1];
return a == b; // false, obj references
};
console.log('arrays', testArray());
var testEmpty = function () {
var a = 0;
var b = []; //""
return a == b; // true, both coerced to num when either is num
};
console.log('empty things', testEmpty());
var testEmpty = function () {
var a = "";
var b = false;
return a == b; // true, both coerced to bool when both bool
};
console.log('bools', testEmpty());
</script></body>
</html>
var testStr = function () {
var a = "5";
var b = "44";
return a > b; // true, lex comparison
};
console.log("num str", testStr());
var testArray = function () {
var a = [1];
var b = [1];
return a == b; // false, obj references
};
console.log('arrays', testArray());
var testEmpty = function () {
var a = 0;
var b = []; //""
return a == b; // true, both coerced to num when either is num
};
console.log('empty things', testEmpty());
var testEmpty = function () {
var a = "";
var b = false;
return a == b; // true, both coerced to bool when both bool
};
console.log('bools', testEmpty());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment