@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 fPrev, fCurr; | |
function fib (n) { | |
var result; | |
if (n < 0) throw Error('invalid given number'); | |
if (n <= 1) { | |
return n; | |
} |
function gcd(a, b) { | |
if (a < 0 || b < 0) throw Error ('positive numbers only'); | |
if (a === 0 || b === 0) | |
return Math.max(a, b); | |
else if (a >= b) | |
return gcd(a % b, b); | |
else | |
return gcd(a, b % a); | |
} |
function get_pos(arr, number) { | |
var l = 0, | |
r = arr.length, | |
m; | |
while (l < r) { | |
m = Math.floor( (l + r) / 2 ); | |
if (number < arr[m]) { | |
r = m; |
function sort(nums) | |
{ | |
if (!nums.length) return nums; | |
var a = [], b = [], p = nums[0]; | |
for (var i = 1; i < nums.length; i++) | |
{ | |
if (nums[i] < p) | |
a[a.length] = nums[i]; |
/** | |
* @module Page | |
*/ | |
modules.define( | |
'page', | |
['i-bem__dom', 'BEMHTML', 'jquery' 'modal'], | |
function (provide, BEMDOM, BEMHTML, $, Modal) { | |
/** | |
* @exports |
/** | |
* @module input_type_tel | |
*/ | |
modules.define( | |
'input', | |
['i-bem__dom', 'jquery'], | |
function (provide, BEMDOM, jQuery, Input) { | |
/* borschik:include:../../libs/intl-tel-input/build/js/intlTelInput.js */ |
var loading = {}, | |
loaded = {}, | |
head = document.getElementsByTagName('head')[0], | |
runCallbacks = function(path, type) { | |
var cbs = loading[path], cb, i = 0; | |
delete loading[path]; | |
while(cb = cbs[i++]) { | |
cb[type] && cb[type](); | |
} | |
}, |
@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 loading = {}, | |
loaded = {}, | |
head = document.getElementsByTagName('head')[0], | |
runCallbacks = function (path, type) { | |
var cbs = loading[path], cb, i = 0; | |
delete loading[path]; | |
while (cb = cbs[i++]) { | |
cb[type] && cb[type](); | |
} | |
}, |
enum Event { | |
enum app: String { | |
case install = "app install" | |
case launch = "app launch" | |
} | |
enum list: String { | |
case created = "list created" | |
case deleted = "list deleted" | |
case refreshed = "list refreshed" |