Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Even Rubber Duck knows JS better than you!

Nikita Galkin
September 08, 2018

Even Rubber Duck knows JS better than you!

Nikita Galkin

September 08, 2018
Tweet

More Decks by Nikita Galkin

Other Decks in Programming

Transcript

  1. class Employee { constructor(role) { this.role = role; } get

    mainResponsibility() { switch (this.role) { case 'Developer': return 'Write Code'; ...
  2. Upgraded Hiring process 1. HR-interview 2. CV-screening 3. Live coding

    as fail fast check 4. Technical interview 5. Test task as second chance 6. Interview with the client 8
  3. Live coding • 20 minutes only • Remote via skype

    with screen-sharing • Without bla-bla bullshit • 4-6 trivial JS tasks at JSfiddle • Easy to see does the code work or not • Googling or Asking is okey 9
  4. const obj = { fullname: 'Yellow Duck', getFullname: function() {

    return this.fullname; } }; const nameGetter = obj.getFullname; // @todo fix this line document.getElementById('name').innerHTML = nameGetter();
  5. const obj = { fullname: 'Yellow Duck', getFullname: function() {

    return this.fullname; } }; const nameGetter = obj.getFullname; // @todo fix this line document.getElementById('name').innerHTML = obj.fullname;
  6. const fullname = 'Yellow Duck'; const obj = { getFullname:

    function() { return fullname; } }; const nameGetter = obj.getFullname; // @todo fix this line document.getElementById('name').innerHTML = nameGetter();
  7. const obj = { fullname: 'Yellow Duck', getFullname: function() {

    return this.fullname; } }; const nameGetter = obj.getFullname.bind(obj); document.getElementById('name').innerHTML = nameGetter();
  8. 17

  9. function wait(timeout) { // @todo implement } wait(1000) .then(() =>

    { document.getElementById('answer').innerHTML = 'Done!'; });
  10. function wait(timeout) { return { then: function(callback) { callback(); }

    } } wait(1000) .then(() => { document.getElementById('answer').innerHTML = 'Done!'; });
  11. function wait(timeout) { setTimeout(function() {}, timeout); } wait(1000) .then(() =>

    { document.getElementById('answer').innerHTML = 'Done!'; });
  12. function wait(timeout) { setTimeout(function() { return Promise(); }, timeout); }

    wait(1000) .then(() => { document.getElementById('answer').innerHTML = 'Done!'; });
  13. function wait(timeout) { return new Promise(r => setTimeout(r, timeout)); }

    wait(1000) .then(() => { document.getElementById('answer').innerHTML = 'Done!'; });
  14. const unfiltered = [1, 2, 3, 5, 1, 5, 9,

    1, 2, 8]; const filtered = removeDuplicates(unfiltered); // filtered should be equal [1, 2, 3, 5, 9, 8] document.getElementById('answer').innerHTML = filtered; function removeDuplicates(arr) { // @todo implement }
  15. const unfiltered = [1, 2, 3, 5, 1, 5, 9,

    1, 2, 8]; const filtered = removeDuplicates(unfiltered); // filtered should be equal [1, 2, 3, 5, 9, 8] document.getElementById('answer').innerHTML = filtered; function removeDuplicates(arr) { return arr.filter(...) }
  16. const unfiltered = [1, 2, 3, 5, 1, 5, 9,

    1, 2, 8]; const filtered = removeDuplicates(unfiltered); // should be [1, 2, 3, 5, 9, 8] document.getElementById('answer').innerHTML = filtered; function removeDuplicates(arr) { const obj = {}; for (const el of arr) { obj[el] = true; } return Object.keys(obj); }
  17. const unfiltered = [1, 2, 3, 5, 1, 5, 9,

    1, 2, 8]; const filtered = removeDuplicates(unfiltered); // filtered should be equal [1, 2, 3, 5, 9, 8] document.getElementById('answer').innerHTML = filtered; function removeDuplicates(arr) { return Array.from(new Set(arr)); }
  18. 32 HAPPY CODING WITH JAVASCRIPT! You can find me at

    twitter as @galk_in Slides are available at speakerdeck.com/galkin or at my site galk.in