@kangax created a new interesting quiz, this time devoted to ES6 (aka ES2015). I found this quiz very interesting and quite hard (made myself 3 mistakes on first pass).
Here we go with the explanations:
(function(x, f = () => x) {
@kangax created a new interesting quiz, this time devoted to ES6 (aka ES2015). I found this quiz very interesting and quite hard (made myself 3 mistakes on first pass).
Here we go with the explanations:
(function(x, f = () => x) {
javascript:(function(){if(window._activeElInterval){clearInterval(window._activeElInterval);delete window._activeElInterval;}else{var activeEl;window._activeElInterval=setInterval(function(){var currentActiveEl=document.activeElement;if(currentActiveEl!==activeEl){activeEl=currentActiveEl;console.log(activeEl);}},200);}})(); |
import React from 'react'; | |
import _ from 'lodash'; | |
/** | |
* Protect a heavyweight setter by caching values locally. | |
* Allows functional controlled components with e.g. a redux backing store, | |
* without dispatching actions on every keypress. | |
* | |
* @param {*} valueProp the value to cache (e.g. a key from mapStateToProps) | |
* @param {*} setterProp the heavyweight setter to protect (e.g. a key from mapDispatchToProps) |
import React, { Component } from "react" | |
import { Machine } from "xstate" | |
import * as PropTypes from "prop-types" | |
class FiniteMachine extends Component { | |
machine = Machine(this.props.chart) | |
state = { | |
data: this.props.reducer(undefined, { type: "@init" }), | |
machineState: this.machine.getInitialState() |
The philosophy behind Documentation-Driven Development is a simple: from the perspective of a user, if a feature is not documented, then it doesn't exist, and if a feature is documented incorrectly, then it's broken.
import Ember from 'ember'; | |
import Changeset from '../lib/changeset'; | |
import validatePresence from '../validators/presence'; | |
let model = { foo: 'bar' }; | |
let validations = { | |
foo: validatePresence() | |
}; | |
let changeset = new Changeset(model, { validations }); |
Download the following repositories and run yarn install
in each:
{ | |
"window.zoomLevel": 0, | |
"editor.tabSize": 2, | |
"editor.renderWhitespace": "all", | |
"editor.minimap.enabled": false, | |
"editor.fontFamily": "Operator Mono,'Fira Code'", | |
"editor.fontLigatures": true, | |
"editor.multiCursorModifier": "ctrlCmd", | |
"editor.formatOnSave": true, | |
"editor.formatOnPaste": true, |
import { h, Component } from 'preact'; | |
/** Creates a new store, which is a tiny evented state container. | |
* @example | |
* let store = createStore(); | |
* store.subscribe( state => console.log(state) ); | |
* store.setState({ a: 'b' }); // logs { a: 'b' } | |
* store.setState({ c: 'd' }); // logs { c: 'd' } | |
*/ |