Skip to content

Instantly share code, notes, and snippets.

View nodelist-to-array-concat.html
<!doctype html>
<html lang="en" dir="ltr">
<head>
<title>NodeList/HTMLCollection conversion/concatenation to array (testing)</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript">
// get elapsed time
function timeElapsed(t) { return ((new Date()).getTime() - t); }
onload = function() {
View gist:179535
// first alert(1), then alert(2)
var foo = 1;
alert(1);
var bar = (function(){ alert(2); })();
// first alert(2), then alert(1)
var foo=1,bar=(function(){alert(2);})();alert(1);
View quirks_detect.js
<html>
<head>
<title>Quirk Mode Test for Safari 2.0.x and other old browsers</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<script type="text/javascript">
// adapted from http://code.google.com/p/doctype/wiki/ArticleCompatMode
document.compatMode || (document.compatMode =
(function() {
var el; (el = document.createElement('div')).style.width = 1;
return el.style.width == '1px' ? 'BackCompat' : 'CSS1Compat';
View easy_error
/* can you spot what is happening here */
/* the alert("X") should never execute */
<script>
onload = function() {
var fn = function() {
alert("X");
}
(function() { })();