Open Side Menu Go to the Top
Register
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** ** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

08-02-2018 , 12:31 PM
super jelly re:bangalore
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-02-2018 , 12:34 PM
Probably. I'm a little concerned my somewhat bro-ey director who I'm going with will try to get me to go out with him every night and splash around USD. Thank god there isn't strip clubs there..

Guess I'll do some research on things to do there and see but I'm sure its just generic office park land. Anyone else ever go there?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-02-2018 , 04:14 PM
Note - I may start posting Netflix questions here in real time at 2pm PDT. It might be fun.

I would never normally do this but because it's Netflix and they already kinda screwed me over once, and the odds of me getting through their *best of the best of the best* filter right now are essentially zero - YOLO.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-02-2018 , 06:36 PM
Lol here's one of the problems. I plugged the output into JS fiddle but don't understand why I get the result = 0 then 2. Anyone?

Code:
var length = 10;
function fn() {
	console.log(this.length);
}

var obj = {
  length: 5,
  method: function(fn) {
    fn();
    arguments[0]();
  }
};

obj.method(fn, 1);
What is the Output?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-02-2018 , 06:40 PM
Quote:
What are several CSS properties used to evenly distribute a row of horizontal DOM elements?

What are some of the advantages to using a CSS pre-processor?

What are a few differences between LESS, SASS, and SCSS?

How do you declare a style variable in SCSS?

What type of UI component would you use for a boolean ON/OFF use-case?

What type of UI component would you use to select between two distinct options for an either/or use-case?

What is the difference between categorical and ordinal values? When should you use each when representing data visually?
And those are the rest. Apparently I'm being tested on CSS - woot.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-02-2018 , 06:48 PM
It looks to me like that first is attempting to gauge how well you understand the vagaries of dereferencing `this`, but other than saying "hey that's not going to work right" I have no idea what it outputs. I'd kind of expect `this` to be undefined.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-02-2018 , 07:05 PM
Jesus christ at that js question. I would look them in the eye and say "it looks like you're asking me if I know that Function.length returns the number of arguments it has, do you do that a lot here at Foo Company? Do you use the arguments keyword a lot?"
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-02-2018 , 07:10 PM
Css questions are decent I guess? Half of them are just UI though? They want you to tell them what a checkbox is used for?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-02-2018 , 07:15 PM
Lol I said switch. Forgot about checkbox.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-02-2018 , 07:17 PM
Quote:
Originally Posted by well named
It looks to me like that first is attempting to gauge how well you understand the vagaries of dereferencing `this`, but other than saying "hey that's not going to work right" I have no idea what it outputs. I'd kind of expect `this` to be undefined.
Quote:
Originally Posted by Grue
Jesus christ at that js question. I would look them in the eye and say "it looks like you're asking me if I know that Function.length returns the number of arguments it has, do you do that a lot here at Foo Company? Do you use the arguments keyword a lot?"
The funny thing about that problem is if you cheat and use jsFiddle (like I tried to do) you get 0,2. I output this in the first case and it's Window.

But theoretically it's 10,2 in some kind of non-window environment. I told them I usually just console.log(this) to see what it is and not waste brainpower trying to guess. Also that I never use the arguments array.

Last edited by suzzer99; 08-02-2018 at 07:22 PM.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-02-2018 , 07:26 PM
Sorry arguments is an array like object not an array, no job for you.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-02-2018 , 07:40 PM
The Netflix problem was one we worked up to that wound up like this. Basically you're creating an iterator of iterators. If an iterator is finished the next() function should just move on to the next one and only return the done response when all iterators are finished. It needs to handle empty iterators as well.

Code:
function chained(...iterators) {
 // stuff
}

let composite = chained([1, 2, 3][Symbol.iterator](), [][Symbol.iterator](), [][Symbol.iterator](), [4, 5, 6][Symbol.iterator]());

console.log(composite.next()); // {value: 1, done: false}
console.log(composite.next()); // {value: 2, done: false}
console.log(composite.next()); // {value: 3, done: false}
console.log(composite.next()); // {value: 4, done: false}
console.log(composite.next()); // {value: 6, done: false}
console.log(composite.next()); // {value: 6, done: false}
console.log(composite.next()); // {done: true}
console.log(composite.next()); // {done: true}

I muddled through it in real time but then came up with this 30 minutes after the codepad session and emailed it to him:

Spoiler:
Code:
function chained(...iterators) {
  let iter = iterators.shift();

  function getValue() {
    if (!iter) return {done: true};
   
    let value = iter.next();
   
    if (!value.done) return value;

    iter = iterators.shift();
    return getValue();
  };
  
  return {
    next: () => {
      return getValue();
    }
  };
}
I feel like it could be cleaner and it bugs me a little that both iter and iterators are outside the scope of getValue. But at least one of them has to be so meh.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-02-2018 , 08:50 PM
Thank you suzzer for posting those.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-02-2018 , 10:21 PM
Code:
const chained = require('concat-iterator');
impl:

Spoiler:
Code:
function* chained() {
  for (let iter of arr(arguments))
    for (let x of iter)
      yield x;
}
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-03-2018 , 12:06 AM
GAHHHHH - that's exactly what he was looking for. I was event thinking that in the back of my mind too.

Spoiler:
Well generators in general.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-03-2018 , 12:46 AM
Here's basically what he was looking for:

Spoiler:
Code:
function* chained(...groups) {
  while(groups.length > 0) {
    let entries = groups.shift();
    while (entries.length > 0) 
      yield entries.shift();
  }
}

let composite = chained([1, 2, 3],[],[],[4, 5, 6]);
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-03-2018 , 01:11 AM
I've spent the last 3-4 hours failing miserably to get my AWS EC2 node app to deploy from my github repo. Enthusiasm for learning AWS is rapidly waning lol.

I just keep getting (Error code: HEALTH_CONSTRAINTS). I've been trying to find some kind of logs. But the logs on the instance seem useless. I can't figure out if the health fail logs are on some other instance. That app deploys fine if I upload the zip file directly.

One weird thing on github it says the AWS oath key thing I created hasn't been used. So probably AWS isn't even trying to connect? I'm triggering the deployment manually from AWS. I haven't even tried to auto-trigger from github commits yet.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-03-2018 , 02:04 AM
Quote:
Originally Posted by suzzer99
Lol here's one of the problems. I plugged the output into JS fiddle but don't understand why I get the result = 0 then 2. Anyone?

Code:
var length = 10;
function fn() {
	console.log(this.length);
}

var obj = {
  length: 5,
  method: function(fn) {
    fn();
    arguments[0]();
  }
};

obj.method(fn, 1);
What is the Output?
Ok, I haven't read past this post.

I'm gonna write out what I think and hopefully people will explain where I am wrong in detail because I feel like I'm about to learn a lot from this and I'm pretty excited.

Code:
var length = 10;
function fn() {
	console.log(this.length);
}
We're creating a global called length which is equal to the javascript integer 10.

We're creating a function that console logs this.length. I am immediately noting that "this" is being used in a weird way here. This is a code style that I haven't seen and is obviously trying to trick us. Because we aren't in an object, or anything, I feel like currently "this" is just pointing to fn(), so length if we executed this function right now would be undefined.

Code:
var obj = {
  length: 5,
  method: function(fn) {
    fn();
    arguments[0]();
  }
};
Ok now we got an object. We have fn() all over this place, so the game is on, here is where "this" is gonna shine.

Length is 5, so I'm thinking right now that in execution context, we just got our "this.length" for our fn().

Code:
obj.method(fn, 1);
Ok so let's figure out our output.

We are invoking method which is:

Code:
function(fn) {
    fn();
    arguments[0]();
  }
This is a method that takes 1 argument, fn and hopefully its a function because we're about to execute it. It is a function so it is executed. We also pass in a second argument to this method, even tho its signature only calls for one, and it doesn't return a function (I think technically that the "console.log(this.length)" of fn() returns undefined) so I'm really not sure wtf this second argument is doing here, again this is some weird trivia ****.

So we are executing fn() and we are seemingly logging 5, but that doesn't seem like the full story. We have this 1 we have to deal with and we have arguments index zero being executed.

Now, fn() doesn't have any type of explicit or implicit return (I don't think), so I feel pretty good about arguments[0]() running, but what it is about to do, I have honestly no ****ing clue.

At this point I could guess, but I don't even know what I should guess at, I'm gonna spend 10-15 seconds googling "arguments[0]" and just see if its some reserved word with special meaning/usage.

Ok I'm back that was like 5 seconds, praise be to google.

So arguments is an array of the arguments passed to a function in non arrow functions.

Ok I'm going back to MDN. I added a function fn() { console.log(5) } and func(1, 2, fn() ) to the arguments example and it printed out my console log first and then the other arguments. It is like my "fn()" was hoisted to the front of the arguments array. That seems cool, but I have no idea why that is happening. And I'm not sure how that helps me here.

I went back to MDN and I changed my fn to:

Code:
function fn() {
 setTimeout( function() {
 	console.log(1000)
 },10 )
}
That outputs: 1, 2, undefined, 1000.

So I'm gonna guess that we get:

"undefined, 5*"

as the output.

Last edited by Larry Legend; 08-03-2018 at 02:17 AM. Reason: meant 5
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-03-2018 , 02:14 AM
Wait function* is a thing? wat

(shows what a JS power user I am)
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-03-2018 , 05:32 AM
If I was faced with this question I would just tell them "Sorry, I don't use the bad parts of js."

Last edited by Wolfram; 08-03-2018 at 05:37 AM.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-03-2018 , 07:16 AM
Quote:
Originally Posted by suzzer99
Lol here's one of the problems. I plugged the output into JS fiddle but don't understand why I get the result = 0 then 2. Anyone?

Code:
var length = 10;
function fn() {
	console.log(this.length);
}

var obj = {
  length: 5,
  method: function(fn) {
    fn();
    arguments[0]();
  }
};

obj.method(fn, 1);
What is the Output?
I would guess the output is
5
5

so that is why I dont look for a new job.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-03-2018 , 07:42 AM
And the rest of suzzers test questions are even more reason I am petrified to look for a new job. Completely confused and unfamiliar.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-03-2018 , 09:09 AM
https://developer.mozilla.org/en-US/...nction_context

The output is 10, 2 (in node).

The first time we call fn we're calling it directly and not as a method or property of an object, which means that this defaults to the global object, where var length = 10 is defined.

The second time fn is called it is done through the arguments array which means this is in the scope of the function itself, so this.length is the number of parameters of the called function. Because the function call is obj.method(fn, 1) the function has two params so 2 is output. The second parameter is just a dangler and not used for anything. You can do e.g. obj.method(fn,1,2,3,4,5,6) and get 10, 7 as the output.

How any of this is supposed to be a useful feature of a programming language is a mystery to me.

lol javascript.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-03-2018 , 12:14 PM
Thanks for that explanation.

I am of two minds on this stuff.

Clearly it is on one hand some very very dumb trivia type stuff.

On the other hand, someone who is an extreme expert in the language should probably be able to reason through it like Wolfram did. If they are looking to filter out someone like myself, then they would be very successful with this question because I don't know the language well enough yet.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-03-2018 , 12:23 PM
I'm pretty skeptical about that being a useful interview question. I feel like if someone hands me that code snippet on a piece of paper the correct response is to draw a big circle around it, then a line through it, then hand it back :P

Although I like "I don't use the bad parts of javascript" as a response also
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote

      
m