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
/* ES5 */ | |
function catFight (action) { | |
var moreActions = Array.prototype.slice.call(arguments, 1); | |
return action + '! ' + moreActions.join('! ') + '!'; | |
} | |
catFight('Slash', 'Hiss', 'Yowl'); | |
// > 'Slash! Hiss! Yowl!' | |
/* >= ES6 */ | |
function catFight (action, ...moreActions) { | |
return action + '! ' + moreActions.join('! ') + '!'; |
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
/* < ES2018 */ | |
var coat = { color: 'tabby', mittens: true }; | |
var catMaru = Object.assign({ name: 'Maru', likes: 'boxes'}, coat); | |
// > { name: 'Maru', likes: 'boxes', color: 'tabby', mittens: true } | |
/* >= ES2018 */ | |
var coat = { color: 'tabby', mittens: true }; | |
var catMaru = { name: 'Maru', likes: 'boxes', ...coat }; | |
// > { name: 'Maru', likes: 'boxes', color: 'tabby', mittens: true } |
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
/* ES5 */ | |
var lol = "cats"; | |
var chars = lol.split(""); | |
// > [ "c", "a", "t", "s" ] | |
/* >= ES6 */ | |
var lol = "cats"; | |
var chars = [ ...cats ]; | |
// > [ "c", "a", "t", "s" ] |
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
/* ES5 */ | |
var cats = [ 'Maru', 'Colonel Meow', 'Grumpy Cat' ]; | |
var moreCats = [ 'Shironeko', 'Zarathustra'].concat(cats); | |
// > [ 'Shironeko', 'Zarathustra', 'Maru', 'Colonel Meow', 'Grumpy Cat' ] | |
/* >= ES6 */ | |
var cats = [ 'Maru', 'Colonel Meow', 'Grumpy Cat' ]; | |
var moreCats = [ 'Shironeko', 'Zarathustra', ...cats ]; | |
// > [ 'Shironeko', 'Zarathustra', 'Maru', 'Colonel Meow', 'Grumpy Cat' ] |
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
/* ES5 */ | |
function dogExplainsCats (behaviour, reason) { | |
if (reason === undefined) { | |
reason = 'evil'; | |
} | |
return 'Why cats ' + behaviour + '? Because cats ' + reason + '.'; | |
} | |
dogExplainsCats('poke you in face when sleeping'); | |
// > 'Why cats poke you in face when sleeping? Because cats evil.' |
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
/* ES5 */ | |
var message = 'The internet is for cat videos.\n' + | |
'A chorus of cats meows from every screen!\n' + | |
'The cuteness is overwhelming.'; | |
/* >= ES6 */ | |
var message = `The internet is for cat videos. | |
A chorus of cats meows from every screen! | |
The cuteness is overwhelming.`; |
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
/* ES5 */ | |
var purpose = 'cat videos'; | |
var message = 'The internet is for ' + purpose + '.'; | |
/* >= ES6 */ | |
var purpose = 'cat videos'; | |
var message = `The internet is for #{purpose}.`; |
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-1.12.1.min.js"></script> | |
<title>ScriptEd WCHS + For Loops - 3/22/16</title> | |
<style> | |
div { padding: 1em; } | |
#vader-example { background-color: yellow; } |
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
<html> | |
<head> | |
<title>BB-8 is great</title> | |
<style> | |
body{ | |
background: black; | |
color: white; | |
width: 700px; | |
margin: auto; | |
} |
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
<html> | |
<head> | |
<title>HTML & CSS: div tags, ids and classes</title> | |
<link rel="stylesheet" type="text/css" href="styles.css"> | |
</head> | |
<body> | |
<!-- Add ids to these paragraphs so that the first has a green background and the second has a red background. --> | |
<!-- HINT: look at the stylesheet to figure out what the correct ids to add are --> | |
<p>I should have a green background!</p> | |
<p>I should have a red background!</p> |
NewerOlder