Last active
July 25, 2023 11:36
-
-
Save bradtraversy/15261a79264528ddb9a380323697f0f7 to your computer and use it in GitHub Desktop.
Code From the Developer Tools Crash Course
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"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<link rel="stylesheet" href="style.css"> | |
<title>Devtools Test</title> | |
</head> | |
<body> | |
<h1>Hello World</h1> | |
<button>Button</button> | |
</body> | |
<script> | |
// console.log('Hello'); | |
// //console.log(myvar); | |
// console.error('An error'); | |
// console.warn('A warning'); | |
// console.dir(document); | |
// console.table([{name:'John', email:'[email protected]', age:33}]); | |
// console.clear(); | |
// console.group('Say Hello'); | |
// console.log('Hello Brad'); | |
// console.log('Hello John'); | |
// console.log('Hello Sally'); | |
// console.groupEnd('Say Hello'); | |
// console.time('Run Loop'); | |
// for (var i = 0; i < 20000; i++) { | |
// console.log(i); | |
// }; | |
// console.timeEnd('Run Loop'); | |
// function greaterThan(a,b) { | |
// console.assert(a > b, {"message":"a is not greater than b","a":a,"b":b}); | |
// } | |
// greaterThan(5,6); | |
// document.querySelector('button').addEventListener('click', loadUsers); | |
// // Load Github Users | |
// function loadUsers(){ | |
// var xhr = new XMLHttpRequest(); | |
// xhr.open('GET', 'https://api.github.com/users', true); | |
// xhr.onload = function(){ | |
// if(this.status == 200){ | |
// var users = JSON.parse(this.responseText); | |
// var output = ''; | |
// for(var i in users){ | |
// output += | |
// '<div class="user">' + | |
// '<img src="'+users[i].avatar_url+'" width="70" height="70">' + | |
// '<ul>' + | |
// '<li>ID: '+users[i].id+'</li>' + | |
// '<li>Login: '+users[i].login+'</li>' + | |
// '</ul>' + | |
// '</div>'; | |
// } | |
// document.getElementById('users').innerHTML = output; | |
// } | |
// } | |
// xhr.send(); | |
// } | |
// Set localstorage - will stay until delete/clear | |
localStorage.setItem('name','John'); | |
// Set sessionstorage - will stay until browser close | |
sessionStorage.setItem('user', 'Will'); | |
// Set cookie | |
document.cookie = "username=John Doe"; | |
</script> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment