Created
July 27, 2015 18:14
-
-
Save mayfer/f4b48fe1d6373f81d8be to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<html> | |
<head> | |
<title>Intro to Javascript</title> | |
<style> | |
body { background: #358; color: #fff; padding: 50px; font-family: sans-serif; } | |
</style> | |
<script> | |
document.addEventListener("mousemove", function(evt) { | |
console.log(evt); | |
var coord = evt.pageX + ", " + evt.pageY | |
document.getElementsByTagName("h1")[0].innerHTML = coord; | |
}); | |
</script> | |
</head> | |
<body> | |
<h1>helloooo</h1> | |
<ul> | |
<li>Item 1 | |
<li>Item 2 | |
</ul> | |
</body> | |
</html> | |
This file contains hidden or 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 numbers = [354, 4, 23, 87, 12102]; | |
var number_exists = function(number, numbers) { | |
// [0, 1, 2, 3, 4] | |
for(var i=0; i<numbers.length; i++) { | |
if(number == numbers[i]) { | |
console.log("FOUND!") | |
return true; | |
} | |
}; | |
return false; | |
} | |
console.log(number_exists(4, [456, 34, 4, 233])); |
This file contains hidden or 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
// puts | |
console.log("hello world"); | |
// number = 5 | |
var number = 5; | |
// $number = 5 | |
number = 5; | |
// def method..end | |
function myfunction(arg1, arg2) { | |
var temporaryFunction = function() { | |
return 10; | |
} | |
var some_val = arg1 * arg2 * temporaryFunction; | |
return some_val; | |
} | |
var myfunction = function(arg1, arg2) { | |
... | |
}; | |
// totally possible | |
var functions = [function(){}, function(){}]; | |
This file contains hidden or 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 sec = 1; | |
var timer = function() { | |
console.log(sec + " second passed"); | |
sec += 1; | |
setTimeout(timer, 1000); | |
} | |
setTimeout(timer, 1000); | |
console.log("runs first"); | |
console.log("END OF FILE"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment