@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) {| var http = require('http'); | |
| /** | |
| * 读取远程文件 | |
| * | |
| * @param {String} url | |
| * @param {Function} cb | |
| * - {Error} err | |
| * - {Buffer} buf | |
| */ |
All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.
elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParentelem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeightelem.getClientRects(), elem.getBoundingClientRect()| // Sort Numbers | |
| function solution(nums){ | |
| return (nums || []).sort(function(a, b){ | |
| return a - b | |
| }); | |
| } | |
| // ------------------------------------------------------------------------------------------------------------------------- | |
| // If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. |