Midwest Dev Chat

MidwestDevChat.com

  • The newest 15 messages in the super-cool #javascript channel.

  • 11/15 15:10:26 Lakia: i defined `debug` outside because it's code i want to reuse, but it would be really nice if its scope was where it was being used. idk if that makes sense
  • 11/15 15:11:54 Lakia: (ignore that the example isn't valid JS. lol)
  • 11/15 15:20:31 Blair: It’s tough to tell what you’re trying to do from that code, but one possible solution might be to turn debug into a higher order function or possibly a decorator
  • 11/15 15:21:53 Blair: IMO literally any solution is better than eval upside_down_face
  • 11/15 15:36:11 Gaynelle: Why not put environment and user in a higher scope where debug() can see it, so you don't have to keep passing it in?
  • 11/15 16:18:36 Chae: everyone uses `eval` in production. It's in `bluebird` and everybody uses `bluebird` troll
  • 11/15 16:19:58 Robt: damnnnn. Interesting stuff: https://stackoverflow.com/a/24989927
  • 11/15 16:25:31 Chae: fascinating
  • 11/15 16:29:34 Gaynelle: fastenating*
  • 11/15 16:29:52 Chae: <#C02TTU11Y|puns>
  • 11/15 16:46:19 Chae: The `toFastProperties()` writeup was truly... eye-opening. I was actually thinking of this other piece of bluebird which uses the function constructor: https://github.com/petkaantonov/bluebird/blob/4...
  • 11/15 17:44:00 Lakia: my example is pretty crappy, but, let's say that debug is a function that takes values and records them. functions a, b, and c are passing in their own locally scoped values into debug. a, b, and c each have unique local variables named `environment` and `user`. I noticed i was always passing them in, and I was trying to get rid of that repetition
  • 11/15 17:44:38 Lakia: yeah, i don't think my use of eval agreed with webpack disappointed
  • 11/16 08:45:37 Gaynelle: Is there a way to make them not local? For instance, will you know them beforehand? You could make an enum of sorts.
      a: [environment],
      b: [environment],
      c: [environment]
    }
    
    debug(type) { const env = environment[type] }
  • 11/16 10:25:29 Lakia: there _might_ be thinking_face
  • *Usernames have been changed to protect the innocent.
We're currently 1111 members strong. Join us!
Request Invite

Check out all the cool channels!

Join the conversation!