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
/** | |
* Takes an object and checks if all given keys exist in the object. | |
* | |
* @param {Object} object | |
* @param {String|Array} keys | |
* | |
* @returns Boolean | |
*/ | |
export const hasKeys = (object, keys) => { | |
if (!(object instanceof Array) && object instanceof Object) { |
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
var hello = document.getElementById('hello'); | |
function Student(name, dob, el) { | |
this.name = name; | |
this.dob = dob; | |
this.el = el; | |
this.getProfile = function() { | |
console.log('In Get Profile', this); | |
return this.name + ' is an idiot'; |
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
var hello = document.getElementById('hello'); | |
function Student(name, dob, el) { | |
var that = this; | |
this.name = name; | |
this.dob = dob; | |
this.el = el; | |
this.getProfile = function() { |
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
class Observer { | |
constructor() { | |
this.observers = []; | |
} | |
subscribe(fn) { | |
this.observers.push(fn); | |
return () => this.observers = this.observers.filter(subscriber => subscriber !== fn); | |
} |
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
const ROMAN = { | |
I: 1, | |
V: 5, | |
X: 10, | |
L: 50, | |
C: 100, | |
D: 500, | |
M: 1000 | |
} |
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
class Subject { | |
constructor(state) { | |
this.state = state; | |
this.observers = []; | |
} | |
getState() { | |
return this.state; | |
} |
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
class Observer { | |
constructor(subject) { | |
subject.registerObserver(this); | |
this.subscribers = []; | |
} | |
subscribe(subscriber) { | |
this.subscribers.push(subscriber); | |
} |
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
const observable = new Subject(10); | |
const observerA = new Observer(observable); | |
const observerB = new Observer(observable); | |
observerA.subscribe(data => { | |
console.log("observerA", data); | |
}); | |
observerB.subscribe(data => { | |
console.log("observerB", data); |
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
class Observer { | |
constructor(state) { | |
this.state = state; | |
this.subscribers = []; | |
} | |
get() { | |
return this.state; | |
} |
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
const animate = document.getElementById('animate'); | |
const btn = document.getElementById('btn'); | |
let enabled = false; | |
btn.onclick = function() { | |
if (enabled) { | |
enabled = false; | |
transition(animate, { |
OlderNewer