Skip to content

Instantly share code, notes, and snippets.

(function() {
// convert a string to a number.
// it uses base 10 by default
var foo = parseInt('78'); // 78
// repeat, with a different number
// this time it's base 8 by default?
var wtf = parseInt('08'); // 0
(function() {
// convert a string to a number.
// it uses base 10 by default
var foo = parseInt('78'); // 78
// repeat, with a different number
// this time it's base 8 by default?
var wtf = parseInt('08'); // 0
(function() {
var available_sizes = {
short: 2,
medium: 5,
long: 10
};
// in dumb browsers calling .long
// throws an error
console.log(available_sizes.long);
(function() {
if (true) {
var foo = 'apple';
}
// foo isn't local
// block scope !== functional scope
console.log(foo); // 'apple'
(function() {
var sorted_array = [1,22,13,4,5].sort(function(a, b) {
// you get a and b to sort.
// if the function returns a..
// negative number: a comes ahead in sort order
// a positive number: b comes first
return a-b;
(function() {
var sorted_array = [1,22,13,4,5].sort(function(a, b) {
// you get a and b to sort.
// if the function returns a..
// negative number: a comes ahead in sort order
// a positive number: b comes first
return a-b;
(function() {
var sorted_array = [1,22,13,4,5].sort();
console.log(sorted_array); // [1, 13, 22, 4, 5]
})();
(function() {
var page_count = 0,
up_page_count = function () {
page_count++;
};
if ( up_page_count() ) {
console.log('I will never run');
sorted_array = [1,22,13,4,5].sort(function(a, b) {
// you get a and b to sort.
// if the function returns a..
// negative number: a comes ahead in sort order
// a positive number: b comes first
return a-b;
});
queue.subscribe do |payload|
begin
language = AlchemyApi::LanguageDetection.get_language_from_text(payload.force_encoding("UTF-8"))[:language]
rescue
end
p language
end