Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brianbancroft/5a7a7a99947701bfffe5782e8e96f3ec to your computer and use it in GitHub Desktop.
Save brianbancroft/5a7a7a99947701bfffe5782e8e96f3ec to your computer and use it in GitHub Desktop.
getEach.html
<!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