Skip to content

Instantly share code, notes, and snippets.

View fdjones's full-sized avatar

Freddie fdjones

View GitHub Profile
// example HTML
<div class="container">
<div data-example="100">
<div class="some-div">
<span>Some text</span>
</div>
</div>
<div data-example="200">
<div class="some-div">
<span>Some text</span>
const foo = (() => {
const bar = str => str.split('');
return {
bar
}
})();
function Hand() {
this.cards = [];
this.score = function () {
var i;
var total = 0;
for (i = 0; i < this.cards.length; i++) {
if (this.cards[i].rank === "A") {
total++;
// Option 1 (wrong)
function superclass() {this.stuff="stuff";}
function subclass(superclass) {}
// Option 2 (wrong)
function superclass() {this.stuff="stuff";}
function subclass() {subclass.prototype = new superclass();}
// Option 3 (the option that I chose) - wrong
function superclass() {this.stuff="stuff";}
// bad?
function foo() {this.stuff="stuff";}
var bar = new foo();
// good...
function foo() {this.stuff="stuff";}
function bar() {}
bar.prototype = new foo();
const mockData = { message: 'Welcome!' };
const controllers = {
createOne(model, body) {
return Promise.resolve(mockData);
},
updateOne(documentToUpdate, update) {
return Promise.resolve(mockData);
},
deleteOne(documentToDelete) {
function ready(fn) {
if (
if (document.attachEvent) {
document.readyState === 'complete' ;
} else {
document.readyState === 'loading';
}
){
fn();
} else {
function ready(fn) {
if (document.attachEvent ? document.readyState === "complete" : document.readyState !== "loading"){
fn();
} else {
document.addEventListener('DOMContentLoaded', fn);
}
}
import React from 'react';
import Task from './Task';
import PropTypes from 'prop-types';
class TaskList extends React.Component {
// eslint-disable-next-line react/sort-comp
constructor(props) {
super(props);
TaskList.updateStatus = TaskList.updateStatus.bind(this);
Blah.propTypes = {
someObj = {
name: PropTypes.string,
age: PropTypes.number
}
}