Created
September 30, 2016 15:33
-
-
Save jamesdabbs/8aa4c799e2a6575cf4bc63c87055dc6e to your computer and use it in GitHub Desktop.
JavaScript explorations
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="https://code.jquery.com/jquery-3.1.1.slim.js" integrity="sha256-5i/mQ300M779N2OVDrl16lbohwXNUdzL/R2aVUXyXWA=" crossorigin="anonymous"></script> | |
<script src="people.js"></script> | |
</head> | |
<body> | |
<button id="asdf">Click Me!</button> | |
</body> | |
</html> |
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
console.log("here"); | |
// console.log(test); | |
// var test = 3; | |
// floop(3,3); | |
var z = 10; | |
var p = { | |
first: "Su", | |
last: "Kim", | |
id: 5 | |
}; | |
p.other = "stuff"; | |
p["test"] = "thing"; | |
console.log(p); | |
console.log('id is', p.id ); | |
console.log('or also', p["id"]); | |
var field = "first"; | |
console.log("name", p[field]); | |
function floop(x,y) { | |
var z = x + (2 * y); | |
// z = x + (2 * y); | |
console.log('z is', z); | |
return z * z; | |
} | |
var out = floop(2,1); | |
floop(3,3); | |
floop(1,1); | |
console.log('out is', out); | |
console.log('z is', z); | |
// floop(2,1); | |
// floop(); | |
// floop(2,1,3,4,5,6,7,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
var people = [ | |
{ | |
id: 1, | |
first: "James", | |
last: "Dabbs" | |
}, | |
{ | |
id: 17, | |
first: "Su", | |
last: "Kim" | |
}, | |
{ | |
id: 4, | |
first: "Russel", | |
last: "Osborne" | |
} | |
]; | |
console.log(people); | |
function printPerson(x) { | |
var text = x.id + ") "; | |
text += x.first + " " + x.last; | |
console.log(text); | |
} | |
function printPeople() { | |
// console.log("here", people); | |
// for (var i = 0; i < people.length; i++) { ... } | |
people.forEach(printPerson); | |
} | |
// $(function() { "..." }) | |
$(document).ready(function() { | |
console.log("ready"); | |
$("#asdf").click(printPeople); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment