@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) {| angular | |
| .module('smartjs').directive('onlyForAdmin', function(ngIfDirective) { | |
| ngIfDirective = ngIfDirective[0]; | |
| return { | |
| transclude: ngIfDirective.transclude, | |
| priority: ngIfDirective.priority, | |
| terminal: ngIfDirective.terminal, | |
| restrict: ngIfDirective.restrict, | |
| link: function($scope, $element, $attr) { | |
| $attr.ngIf = 'user.isAdmin'; |
| angular | |
| .module('smartjs').directive('onOutsideClick', function($parse) { | |
| return { | |
| restrict: 'A', | |
| link: function($scope, $element, $attr) { | |
| var element = $element[0]; | |
| var fn = function() { | |
| $scope.$eval($attr.onOutsideClick); | |
| }; | |
| var onBodyClickHandler = function(ev) { |
| var DIRECTION_DOWN = -1 | |
| var DIRECTION_NONE = 0 | |
| var DIRECTION_UP = 1 | |
| function HardwareElevator(){}; | |
| HardwareElevator.prototype = { | |
| moveUp:function(){console.log('moving up');}, | |
| moveDown:function(){console.log('moving down');}, | |
| stopAndOpenDoors:function(){console.log('stopping and opening doors');}, | |
| getCurrentFloor:function(){console.log('getting current floor');}, |
| // In global NS to make debug more easier | |
| var PAGES_DELAY = 3000; | |
| var profiles = []; | |
| function step1() { | |
| console.log(`Process page: ${window.location}`); | |
| $('a[href*="/profile"]').toArray().forEach((a) => profiles.push(a.getAttribute('href'))); | |
| console.log(profiles.length, $('a[href*="/profile"]').length); | |
| if(!$('a.page-link.next').length) { | |
| return; |
| // что возвращает эта функция? | |
| (function fun(Infinity, length, __proto__) | |
| { | |
| return [,,~0.[0|0]][fun.__proto__.length && Infinity, -~String(this).length >> __proto__] << (0. === .0) + Infinity; | |
| }).apply(typeof fun, [,,2]); | |
| // рассмотрим массив с аргументами: | |
| // "0" in [,,2] => false | |
| // "1" in [,,2] => false |
@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) {| const { | |
| buildSquareStr | |
| } = require('./buildSquareStr'); | |
| const assert = require('assert'); | |
| const SQUARES = { | |
| 1: `■`, | |
| 3: [`□□□`, `□■□`, `□□□`].join('\n'), | |
| 5: [`■■■■■`, `■□□□■`, `■□■□■`, `■□□□■`, `■■■■■`].join('\n'), | |
| 7: ['□□□□□□□', '□■■■■■□', '□■□□□■□', '□■□■□■□', '□■□□□■□', '□■■■■■□', '□□□□□□□'].join('\n'), |
| const { | |
| getChange | |
| } = require('./getChange'); | |
| const assert = require('assert'); | |
| const TESTS = [{ | |
| dealDetails: [1, 1], | |
| change: [0, 0, 0, 0, 0, 0] | |
| }, | |
| { |
| { | |
| "name": "ws-proxy", | |
| "version": "1.0.0", | |
| "description": "", | |
| "main": "index.js", | |
| "scripts": { | |
| "test": "echo \"Error: no test specified\" && exit 1" | |
| }, | |
| "author": "", | |
| "license": "ISC", |
| export interface News { | |
| loading: boolean; | |
| entities: string[]; | |
| } |