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

08-05-2018 , 03:40 PM
I'm trying to avoid installing grunt or gulp for this. Is there a cleaner way to run nodemon or something similar (PM2?) locally that all the kids are using these days?

Other dumb question - is anyone still using Sublime? Of course my linter (jshint) is erring out and I don't the [all day] it usually takes to debug it. I was fighting with ES Lint earlier and never got it working either. Worst thing about Sublime by far. Every other IDE that stuff just works flawlessly out of the box.

Last edited by suzzer99; 08-05-2018 at 04:07 PM.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-05-2018 , 04:34 PM
Quote:
Originally Posted by suzzer99
Right. But when I turn this over they'll be running it on their local dev machines, and I don't know the IP. I can always have them tell me and then open it up, but that seems sub-optimal.



As far as the other questions - the app needs to be on node, but I can use any SQL db.



I thought I could maybe use a hosted DB so they wouldn't have to install one locally to run the project. But it seems like maybe hosted DBs aren't designed to just open up to any app with credentials.


You can also open it to the world which probably isn’t a problem for a toy problem with a public dataset. But agreed that this doesn’t seem like the right approach for a homework problem.

SQLite also seems reasonable.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-05-2018 , 05:39 PM
I use nodemon/pm2 still idk, seems fine.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-05-2018 , 10:28 PM
Quote:
Originally Posted by PJo336
The arguments part was really, really dumb, but knowing the scoping of this seems like a foundational thing to know
The thing I realize now that made me think this was undefined in the first calling was that I have been writing code in use strict mode for so long I forgot i took it for granted in this case.

Can someone clarify for me if in use strict mode in a stand alone function if it points to the function or if it is just undefined. I feel like I wrongly thought if it was in a standalone anonymous function it was undefined but if it was in a stand alone named function this was the named function.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-06-2018 , 11:51 AM
without the arguments part of that question this wouldn't have pointed towards the function itself? also, since we are using this.length as opposed to this.count, a smart interviewee might remember that there is a default length attribute attached to functions in javascript.

using the question as excuse to not hire someone would be dumb, but overall i thought it was pretty cool.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-06-2018 , 11:56 AM
Larry,

https://jsbin.com/situfukeha/1/edit?...console,output

Last edited by OmgGlutten!; 08-06-2018 at 12:07 PM.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-06-2018 , 12:01 PM
Like most of interview questions its terrible because not once does any javascript developer do anything with the concepts that are being explored in that question. I can't think of the last time I had to worry about what "this" was and when. I haven't made a non React class in 5 years.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-06-2018 , 12:08 PM
Hmm, we still have projects written in Angular.js so I use it often.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-06-2018 , 12:36 PM
I guess thats not totally right, there are some times when calling methods inside of other methods where I would need to keep track of this and when its an arrow function and when its not and use .call on occasion but definitely nothing like that interview question which is just bizarre to me.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-06-2018 , 12:48 PM
Quote:
Originally Posted by Grue
I guess thats not totally right, there are some times when calling methods inside of other methods where I would need to keep track of this and when its an arrow function and when its not and use .call on occasion but definitely nothing like that interview question which is just bizarre to me.
I was gonna say, I used setInterval(this.foo, 1000) the other day and was a little surprised to find that inside of foo(), 'this' was the global this object, not the object that contained the function foo.

In C++ and java "self" or "this" is (I think) always the object the function is contained in. In python, class functions take a self parameter, but it's auto populated in cases where you invoke a class method like "this.foo() or mything.foo()"

It seems like an odd choice to treat all functions as essentially unbound. Anyway it's not hard to fix, but I was surprised.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-06-2018 , 01:03 PM
Well setInterval is really global.setInterval, so inside of that this would be bound to its calling object just like any other method. Super common js gotcha though.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-06-2018 , 01:11 PM
Which leads to the lovely:

Code:
const me = this;
outside your setInterval loop.

Or does const even work like var used to in that spot? Haven't tried it in a while.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-06-2018 , 01:19 PM
I've now had my 4th or 5th recruiter contact me about a senior node dev job that's 15 minutes from my house and almost perfectly lines up with my experience.

Buuuuuuut it's the company I bombed the codepad session on my first day back from my trip. Of course they never come with the name of the company up front for some reason.

So I always have to interact with them just to make sure. Then for some reason they can't process what I'm saying. So they just keep asking me questions like I didn't just tell them I bombed a codepad sesssion so bad there's no way they are interested. "So you would you like us to submit your resume?". Did you listen to ANYTHING I just said? Sure, go ahead - doesn't matter to me.

That company is probably about to put out a restraining order on me.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-06-2018 , 02:00 PM
Quote:
Originally Posted by Grue
Well setInterval is really global.setInterval, so inside of that this would be bound to its calling object just like any other method. Super common js gotcha though.
I guess it kind of depends on where the boundaries for binding are. When I see a line like

Code:
setInterval(this.foo, 1000)
I think that this.foo will resolve first, and then be passed to setInterval. Are you saying that the arguments of javascript functions are processed in the scope of the interior of the function call, not the surrounding block?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-06-2018 , 02:59 PM
Suzzer,

You don't lose anything by sending them that link to the medium article you posted and asking for a second chance.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-06-2018 , 03:23 PM
That's not anywhere in the recruiter script so there's no way it gets through to the actual company.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-06-2018 , 03:42 PM
Quote:
Originally Posted by OmgGlutten!
I obviously never use var either
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-06-2018 , 03:52 PM
Quote:
Originally Posted by OmgGlutten!
On the other hand, if you just write an HTML file and open it in the browser directly you get undefined for the first call to fn() (at least in Chrome and Firefox):

Code:
<html>
<head>
<title>Hi</title>
<head>
<body>
<script type="text/javascript">
  'use strict';
  var length = 10;

  function fn() {
    console.log(this);
    console.log(this.length);
  }

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

  object.method(fn, 1);
</script>
</body>
</html>
I suspect that the difference has to do with the context in which jsbin evaluates the javascript , but I confess I don't really know.

It's made me think I should brush up on some of this arcana. I tend to only use `this` in ES6 classes (well, or in typescript which we compile down to ES5 but then it does it's own "var _this = whatever;" thing) and I got used to just making it behave normally and ignoring the oddities.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-06-2018 , 04:28 PM
I have no doubt that in use strict mode using const it should be undefined.

Using var may usurp use strict mode in something like JSbin or codepen.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-06-2018 , 04:34 PM
When I say "it's undefined" I mean `this` and not `length`. I don't think var/const matters here. Well, at least not in a browser. Google suggests there's something about using const with strict mode in older versions of node, but I'm not sure if that's what you mean?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-06-2018 , 04:39 PM
Yea I mean this should be undefined in a standalone function in use strict.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-06-2018 , 07:23 PM
The more I think about it the more all this testing us for deep knowledge of this and such feels like old school C devs trashing Java devs for not knowing how to do bit arithmetic.

Or old school command line devs trashing IDE devs for not knowing how to write a proper bash compile script.

I'm sure old vacuum tube programmers trashed these new fangled transistor devs for not knowing how to tune their clock rate or w/e.

In a node/express + react world - is it really necessary to know every JS quirk? Will it even matter in 5-10 years?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-06-2018 , 11:04 PM
Quote:
Originally Posted by suzzer99
Or old school command line devs trashing IDE devs for not knowing how to write a proper bash compile script.
I think this one is at least somewhat valid. All of our **** is built with a combination of bash scripts and CMake. Our build servers don't run IDEs.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-06-2018 , 11:08 PM
Quote:
Originally Posted by suzzer99
like old school C devs trashing Java devs for not knowing how to do bit arithmetic.
Finally something I can get behind
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-07-2018 , 12:09 AM
I am not really a fan of asking esoterica for a language. Like, asking about gotchas that people actually come across that cause bugs or waste time, ok. I don't think the "this" example suzzer posted is one of those, really. Even if it is, as someone who has only dabbled in JS, I feel like it's pretty easy to figure out that you have a "this" that's different than the one you expected, and I expect any JS developer to know that it's a "thing" and have tools to figure out what happened.

That might be more interesting, to turn the problem around. Hey this code prints '2' but we think it should print '5', can you tell why and/or fix it? Even that may be kind of pointless, I dunno.

There are some little bits of python trivia that I've collected over the years, things that stumped me for a while, then I learned that little idiosyncracy and added it to the list of stuff to avoid or try to remember. I have a toooooon of this stuff from C++. There are books on C++ that might as well be called "yeah this compiles and it usually works but please do NOT do this"

Regarding the gate-keeping aspects, there will always be a need for *some* people to know the esoterica. This "this" nonsense might not be needed for a react dev, but I would be it is something that someone who works on react itself will need to know, or something that someone who is working on the core of node itself should know. There are still people who do assembly and understand processors at a very deep level. But not all of us need to.

I have to interview someone next week. I know what information I need to get from the interview but I'm not sure how to get it. By far the most effective way would probably be to pay him for a few weeks work to implement some portion of what I want and see if I like the results. But this isn't really very practical. The real pain in this particular case is that I don't actually know how to do what I want him to do, so I can't even ask him some detailed questions and see if his answers are "right" because I don't know the right answers. I don't think anyone at my company does - if they did, I think they would be working on this project right now.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote

      
m