Created
May 5, 2016 00:59
-
-
Save brianbancroft/5a7a7a99947701bfffe5782e8e96f3ec to your computer and use it in GitHub Desktop.
getEach.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
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title></title> | |
<meta name="description" content="The HTML5 Herald"> | |
<meta name="author" content="SitePoint"> | |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"> | |
<!--[if lt IE 9]> | |
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> | |
<![endif]--> | |
</head> | |
<body> | |
This is all JS, here... | |
<script src="https://code.jquery.com/jquery-2.2.3.min.js" integrity="sha256-a23g1Nt4dtEYOj7bR+vTu7+T8VP13humZFBJNIYoEJo=" crossorigin="anonymous"></script> | |
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> | |
<script> | |
$(document).ready(function(){ | |
let specialArr = ['H', {arr: ['e'], str: 'l'}, 'l', [{letter: 'o'}]]; | |
function deepEach(specialArr, f){ | |
function goThrough(input){ | |
let keys = Object.keys(input); | |
for (let i = 0; i < keys.length; i++) { | |
getCase(input[keys[i]]); | |
} | |
} | |
function getCase(input){ | |
getType = typeof input; | |
if (getType == "object" || getType == "array") { | |
goThrough(input) | |
} else { | |
f(input); | |
} | |
} | |
goThrough(specialArr); | |
} | |
deepEach(specialArr, console.log.bind(console)); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment