Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ JavaScript equality comparison is a crazy thing, sometimes.
When in doubt, use three equals signs.

You can view the demo [here](http://dorey.github.io/JavaScript-Equality-Table/).

You can also check out a new, [unified version of the equality table](http://dorey.github.io/JavaScript-Equality-Table/unified/).
37 changes: 37 additions & 0 deletions unified/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>JS Comparison Table</title>
<link rel="stylesheet" href="unified_comparison_table.css" type="text/css" media="all" title="simple" charset="utf-8">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/jquery-ui.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" src="unified_comparison_table.js"></script>

<!-- Inspired by this post:
http://blog.codekills.net/archives/89-Equality-in-JavaScript.html

2013-Nov-11. Correcting issue where "[]===[]" was incorrectly marked as true.
-->
</head>
<body>
<div id="content">
<h3>Equality in JavaScript</h3>
<div id="table"></div>
<div id="key"></div>
<br style="clear:both">
</div>
<script type="text/javascript" charset="utf-8">
/*
Strings in backticks (`) are evaluated.
*/
var values = [true, false, 1, 0, -1, "`'true'`", "`'false'`", "`'1'`", "`'0'`", "`'-1'`",
"", "`null`", "`undefined`", "`[]`", "`{}`", [[]], [0], [1], "`parseFloat('nan')`"];

buildUnifiedComparisonTable(values).appendTo("#table")
buildKeyTable().appendTo("#key")
</script>
</body>
</html>
97 changes: 97 additions & 0 deletions unified/unified_comparison_table.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
body {
margin: 0;
}
#content {
width: 1000px;
margin: 0 auto;
}
#table, #key {
float: left;
}
#table {
width: 720px;
}
#key {
margin-top: 120px;
width: 280px;
}

table.comparisons {
border-spacing: 0;
color: #444;
}
table.comparisons p.desc {
margin: 0;
font-style: italic;
color: #666;
font-size: 14px;
}
table.comparisons td.row.header {
text-align: right;
font-family: Monospace;
font-size: 15px;
font-weight: 600;
}
table.comparisons td.row.header span {
color: #eee;
margin-right: -4px;
}
/*table.comparisons td.row.header.true {
background-color: #f8f8f8;
}*/
table.comparisons td.row.header.true span {
color: #aaa;
}
table.comparisons.key td {
padding: 6px 0;
}
table.comparisons.key td.label {
padding-left: 6px;
}
table.comparisons td.cell {
padding: 1.5px;
cursor: pointer;
}
table.comparisons td.cell div {
width: 25px;
height: 25px;
background-color: #ece3e2;
border: 2px solid #cecece;
border-radius: 3px;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
text-align: center;
line-height: 27px;
color: #c9c9c9;
}
table.comparisons td.strict-equality div, table.comparisons td.loose-equality div {
border-color: #817D7D;
background-color: #dbdbdb;
color: #817D7D;
}
table.comparisons td.strict-equality div {
color: #5f5f5f;
border-color: #464646;
background-color: #818181;
font-size: 28px;
font-weight: bold;
}
table.comparisons td.header.col {
height: 90px;
}
table.comparisons td.header.col span.rotate {
position: absolute;
font-family: Monospace;
font-size: 15px;
font-weight: 600;
-moz-transform:rotate(90deg);
-webkit-transform:rotate(90deg);
-o-transform:rotate(90deg);
-ms-transform:rotate(90deg);
transform:rotate(90deg);
}
table.comparisons .expression {
font-size: 13px;
color: #666;
padding-left: 8px;
}
Loading