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(number){ | |
console.log(number); // 2 | |
number = 1; | |
console.log(arguments[0]); // 1 | |
}(2)); | |
(function(number){ | |
"use strict"; | |
console.log(number); // 2 | |
number = 1; |
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
//Routing | |
hrouter("home", function () { | |
$('#text').html("Home ! "); | |
}); | |
//Parameters | |
hrouter("home/:page", function (page) { | |
$('#text').html("Home page #" + page); | |
}); |
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
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script> | |
<script> | |
var map; | |
var coords = new google.maps.LatLng(32.49847,-116.962852); | |
function initialize() { | |
var mapOptions = { | |
zoom: 15, | |
center: coords | |
}; |
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
// Gets the greatest common divisor | |
function gcd(p, q) { | |
if (q == 0) return p; | |
// remainder | |
var r = p % q; | |
return gcd(q, r); | |
} |
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 run_length_encoding (string) { | |
var encoded = ""; | |
var i = string.length; | |
var counter = 1; | |
var character; | |
var temp; | |
temp = string.charAt(i-1); | |
while(i--) { | |
character = string.charAt(i-1); | |
if (temp == character && i > 0) { |
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
YUI.namespace("module"); | |
YUI.module = (function () { | |
return { | |
publicmethod: function () { | |
return "hello world"; | |
} | |
} | |
}()); |
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 (){ | |
var Shape = function (type) { | |
var shapes = { | |
straight: [ | |
[1,1,1,1,1] | |
], | |
square: [ | |
[1,1], | |
[1,1] |
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 uniquewords(string) { | |
var length = string.length, | |
chars = {}; | |
// it should | |
if (length > 256) return false; | |
for (var i = 0; i < length; i++) { | |
if (!chars[string[i]]){ | |
chars[string[i]] = true; | |
} else { | |
return false; |
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 textToBin(text) { | |
var length = text.length, | |
output = []; | |
for (var i = 0;i < length; i++) { | |
var bin = text[i].charCodeAt().toString(2); | |
output.push(Array(8-bin.length+1).join("0") + bin); | |
} | |
return output.join(" "); | |
} | |
textToBin("!a") // => "00100001 01100001" |
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 model = {}; | |
Object.observe(model, function(changes){ | |
changes.forEach(function(change){ | |
console.log(change.type, change.name, change.oldValue); | |
}); | |
}); | |
model.name = "Pluto"; // Observe log => add name undefined | |
model.name = "Mars"; // Observe log => update name Pluto |
OlderNewer