Guidelines: The following exercise questions should take 1-2 hours, Put your answers after each question - try to give some short explanation for your
Candidate Name: Pery Date: 12/02/2020
inport {flatObject} from './example.js' | |
const obj = {aaa:{bbb:{c:1,d:7}}, bb:{vv:2}} | |
console.log(flatObject(obj)} | |
// aaa.bbb.c: 1 | |
// aaa.bbb.d: 7 | |
// aaa.bbb: {c: 1, d: 7} | |
// aaa: {bbb: {…}} | |
// bb.vv: 2 |
function Dispenser(filter, sort, requestSize = 25, pageSize) { | |
let pages = 0; | |
let rowCount = 0; | |
let contentsPool = []; | |
let items = []; | |
Dispenser.rowCounts = _ => rowCount; | |
Dispenser.getItem = id => items.find(item => item.dbId == id); | |
return async function dispenses() { |
diable catch
$ npm run build && http-server -c-1
minus 1
//https://stackoverflow.com/questions/55431060/inherit-like-from-two-or-more-build-in-objects-in-js-map-eventtarget/55443368# | |
function CreateMix(...classes) { | |
return function Mixed(){ | |
const instances =[this, ... classes.map(cls => new cls(...arguments))] | |
const weakbind = (proxy,fn,obj) => new Proxy(fn, { | |
apply(fn, thisArg, props){ | |
return fn.apply(proxy === thisArg? obj:thisArg ,props); | |
}}) |
const fs = require('fs'); | |
const readline = require('readline'); | |
const {google} = require('googleapis'); | |
// If modifying these scopes, delete token.json. | |
const SCOPES = ['https://www.googleapis.com/auth/spreadsheets.readonly']; | |
// The file token.json stores the user's access and refresh tokens, and is | |
// created automatically when the authorization flow completes for the first | |
// time. | |
const TOKEN_PATH = 'token.json'; |
var data = [{a:1, b:2},{c:3,b:2},{d:4,a:1}]; | |
objectsToTableRows(data); | |
/* return ... | |
{ | |
headers:(4) ["a", "b", "c", "d"], | |
rows:Array(3) | |
0:(2) [1, 2] | |
1:(3) [undefined × 1, 2, 3] | |
2:(4) [1, undefined × 2, 4] |
function addToBookmark(title,href){ | |
if (window.sidebar && window.sidebar.addPanel) { // Mozilla Firefox Bookmark | |
window.sidebar.addPanel(title,href,''); | |
} else if(window.external && ('AddFavorite' in window.external)) { // IE Favorite | |
window.external.AddFavorite(href, title); | |
} else if(window.opera && window.print) { // Opera Hotlist | |
this.title = title; | |
return true; | |
} else { // webkit - safari/chrome | |
alert('Press ' + (navigator.userAgent.toLowerCase().indexOf('mac') != - 1 ? 'Command/Cmd' : 'CTRL') + ' + D to bookmark this page.'); |
function copyText(){ | |
var code = document.querySelector('pre').innerText; | |
var select = document.querySelector('#clipboard'); | |
select.value = code; | |
select.select(); | |
try { | |
document.execCommand('copy'); | |
alert('Text copied to clipboard!'); | |
} catch (err) { |
function loaderScript(scriptUrl){ | |
return new Promise(function (res, rej) { | |
let script = document.createElement('script'); | |
script.src = scriptUrl; | |
script.type = 'text/javascript'; | |
script.onError = rej; | |
script.async = true; | |
script.onload = res; | |
script.addEventListener('error',rej); | |
script.addEventListener('load',res); |