View d3-transition-as-named-function.js
function myTransitionSettings(transition) {
transition
.delay(0)
.duration(100)
.style('background', 'blue')
}
d3.transition().call(myTransitionSettings)
View check-scheduled-transitions-in-D3.js
function checkScheduledTransitions(element) {
const transitions = element.__transition
if (transitions) {
return Object.keys(transitions).length
} else {
return false
}
}
View ComputedStyleResponsiveDesign.js
const { width, height } = window.getComputedStyle(document.querySelector(`.someElemClass`))
View destructuring-in-es6.md

Given the data structure:

const person = {
  first: 'Wes',
  last: 'Bos'
}

You can extract out the variables with this destructuring syntax:

View .gitignore
# tsconfig.json # For example ignore a TypeScript file used in the build process
.gitignore # Ignore this new .gitignore file as we don't wish to commit it into the repo (since its just for local development)
View running-jasmine-tests-in-the-browser.html
<!DOCTYPE html>
<html>
<head>
<!-- META DATA -->
<meta name="description" content="Running Jasmine tests in the browser">
<meta charset="utf-8">
<title>Running Jasmine tests in the browser</title>
<!-- STYLES -->
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/jasmine/2.5.2/jasmine.min.css">
<!-- SCRIPTS -->
View array-methods-in-javascript-filter-map-reduce.js
var data = ['apple', 'pear', 'orange', 'orange', 'apple', 'lime', 'lime'];
data
.filter((item, index, array) => item !== 'pear') /* Let's filter out all pears (as they are horrible!) */
.reduce((total, item, index, array) => {
if (total.indexOf(item) === -1) total.push(item); // Only add unique items to the array (de-duplication)
return total; // Return the cumulative total
}, [] /* Initial value, can be any primitive e.g. [], boolean etc */)
.map((item, index, array) => item + ' juice') /* Add the word 'juice' to the end */
.reduce((total, item, index, array) => {
View zoom-and-pan.css
transform: scale(2); /* Zoom in by 100% */
transform-origin: 50% 50%; /* Pan to the center of the screen */
-webkit-transform: scale(2); /* Zoom in by 100% */
-webkit-transform-origin: 50% 50%; /* Pan to the center of the screen */
View elem-class-toggle.js
var elem = document.querySelector('.some-important-element');
var bool = false;
elem.classList.toggle('class-I-want-to-add-or-remove', bool);
View CSS Font-Size Units
1em (variable) = 12pt (fixed) = 16px (fixed) = 100% (variable)