Skip to content

Instantly share code, notes, and snippets.

Created October 7, 2015 12:02
Show Gist options
  • Save anonymous/dda13eac813c57b55fbb to your computer and use it in GitHub Desktop.
Save anonymous/dda13eac813c57b55fbb to your computer and use it in GitHub Desktop.
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