This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function f(a, b) { | |
alert(a); | |
alert(b); | |
} | |
f(1); // a gets 1, while b is undefined | |
f(1, 2, 3); // the 3 is ignored |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var a = '1' + 1; | |
var b = '1' - 1; | |
var c = '1' * 1; | |
var d = '1' / 1; | |
alert(a === '11'); // is a string | |
alert(b === 0); // is an integer | |
alert(c === 1); // is an integer | |
alert(d === 1); // is an integer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var s = 'abc abc abc'; | |
alert(s.replace(/abc/, 'xyz')); // outputs 'xyz abc abc' | |
alert(s.replace(/abc/g, 'xyz')); // outputs 'xyz xyz xyz' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
C.name AS ColumnName, | |
T.name As DataType, | |
C.max_length AS Length | |
FROM sys.columns AS C JOIN sys.types AS T ON C.user_type_id = T.user_type_id | |
WHERE c.object_id = OBJECT_ID('YOUR_TABLE_NAME_HERE') | |
ORDER BY c.column_id; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ColumnName DataType Length | |
========== ======== ====== | |
ID int 4 | |
Title varchar 255 | |
Blurb varchar 255 | |
IsActive bit 1 | |
Created datetime 8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// this is bad | |
function imageLoaded(i) { | |
alert(i); | |
} | |
for (var i = 0; i < max; i++) { | |
var image = new Image(); | |
image.onload = imageLoaded(i); | |
// more irrelevant stuff here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// better, but still not good | |
function imageLoaded(i) { | |
alert(i); | |
} | |
for (var i = 0; i < max; i++) { | |
var image = new Image(); | |
image.onload = function () { imageLoaded(i) }; | |
// more irrelevant stuff here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// hooray! | |
function imageLoaded(i) { | |
return function () { | |
alert(i); | |
} | |
} | |
for (var i = 0; i < max; i++) { | |
var image = new Image(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ul id="nav"> | |
<li><a href="#">Home</a></li> | |
<li> | |
<a href="#">Shows</a> | |
<ul> | |
<li><a href="#">30 Rock</a></li> | |
<li><a href="#">Doctor Who</a></li> | |
<li><a href="#">The IT Crowd</a></li> | |
<li><a href="#">The Office</a></li> | |
<li><a href="#">Star Trek</a></li> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#nav { | |
overflow: auto; | |
} |