Last active
August 29, 2015 14:06
-
-
Save jotak/eac2aca66591b3b7cbb2 to your computer and use it in GitHub Desktop.
Does Typescript make javascript safe? Not so sure about that...
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
// ... | |
app.get(libRoot + '/get/:start/:count', function(req, res) { | |
getSongsPage([/*some data*/], req.params.start, req.params.count); | |
// ... | |
}); | |
// ... | |
function getSongsPage(allSongs: SongInfo[], start: number, count: number): SongInfo[] { | |
console.log("start=" + start); | |
console.log("count=" + count); | |
console.log("start + count=" + (start + count)); | |
console.log("typeof start=" + typeof start); | |
console.log("typeof count=" + typeof count); | |
console.log("typeof (start + count)=" + typeof (start + count)); | |
var end: number = Math.min(allSongs.length, start + count); | |
if (end > start) { | |
return allSongs.slice(start, end); | |
} | |
return []; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See also some nice articles: "Why TypeScript Isn't the Answer" http://www.walkercoderanger.com/blog/2014/02/typescript-isnt-the-answer/ from serie of articles "The JavaScript Minefield"