@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) {
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> | |
///////////////////////////////////////////////////////// |
/* Ligatures */ | |
.mtk16, | |
.mtk26, | |
.mtk36, | |
.mtk39 { | |
font-family: "Fira Code"; | |
font-weight: 900; | |
} | |
/* Keywords, decorators, comments */ |
// Flexible Compound Components with context | |
import React from 'react' | |
import {Switch} from '../switch' | |
// Right now our component can only clone and pass props to immediate children. | |
// So we need some way for our compound components to implicitly accept the on | |
// state and toggle method regardless of where they're rendered within the | |
// Toggle component's "posterity" :) | |
// |
@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);}})(); |
<form> | |
<div> | |
<label for="text">Text Input</label> | |
<input type="text" id="text" required> | |
</div> | |
<div> | |
<label for="minmaxlength">Text with Min and Max Length</label> | |
<input type="text" id="minmaxlength" minlength="3" maxlength="12"> | |
</div> |
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) |
{ | |
"extends": "airbnb", | |
"env": { | |
"browser": true, | |
"node": true, | |
"es6": true | |
}, | |
"plugins": [ | |
"react", | |
"jsx-a11y", |
Arguments: | |
/usr/local/Cellar/node/9.7.1/bin/node /usr/local/Cellar/yarn/1.5.1/libexec/bin/yarn.js run build | |
PATH: | |
/Users/tony/.rvm/gems/ruby-2.3.3/bin:/Users/tony/.rvm/gems/ruby-2.3.3@global/bin:/Users/tony/.rvm/rubies/ruby-2.3.3/bin:/usr/local/mysql/bin:/usr/local/opt/openssl/bin:/usr/local/opt/curl/bin:/usr/local/opt/python@2/libexec/bin:/usr/local/opt/php71/bin:/Users/tony/.composer/vendor/bin:/usr/local/opt/curl/bin:/Users/tony/bin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:./node_modules/.bin:/usr/local/bin:/usr/local/opt/go/libexec/bin/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/mysql/bin:/usr/X11/bin:/Users/tony/.rvm/bin | |
Yarn version: | |
1.5.1 | |
Node version: |