|
Knifegrab posted:Would such a pause be indefinite though? The script doesn't just hiccup, it straight up fails to continue. Oh, no - I didn't realize you meant it was hanging indefinitely.
|
# ? Oct 19, 2015 20:29 |
|
|
# ? Jun 5, 2024 19:38 |
|
Munkeymon posted:Oh, no - I didn't realize you meant it was hanging indefinitely. Yeah its just failing to resume enitrely. Going to figure out where exactly its happening and then likely will add a promise timeout function.
|
# ? Oct 19, 2015 20:59 |
|
You might be running off the end of the event loop, I recall that being annoying to debug.
|
# ? Oct 19, 2015 21:00 |
|
Subjunctive posted:You might be running off the end of the event loop, I recall that being annoying to debug. What exactly do you mean here? If I were compeltely the loop (which shouldn't happen) I'd have seen it in the logs so I would assume you are referring to something else.
|
# ? Oct 19, 2015 21:14 |
|
https://developer.mozilla.org/en-US/docs/Web/JavaScript/EventLoop (I assume)
|
# ? Oct 19, 2015 21:17 |
|
I must be missing something, because I can't the following JSON result to output:code:
I've tried putting the P,1 in brackets and quotes but I keep getting JSHint errors when trying to console log the variable. It's weird because mustache.js has no problem rendering fields with commas, but the JS console isn't liking it.
|
# ? Oct 20, 2015 15:43 |
|
kloa posted:I must be missing something, because I can't the following JSON result to output: Err, that doesn't look like valid JS or JSON. What's it supposed to do? Mustache probably does some magical handling of "fields" like that when rendering.
|
# ? Oct 20, 2015 17:55 |
|
Well I'm phone posting, so I short handed the parsed JSON result that's going into the variable. I can output the parsed JSON as an object to the console, but trying to display a single field isn't working.
|
# ? Oct 20, 2015 18:30 |
|
kloa posted:Well I'm phone posting, so I short handed the parsed JSON result that's going into the variable. Could you try: code:
|
# ? Oct 20, 2015 18:32 |
|
That was it! I'm a dummy and was trying to do ".["P,1"]" instead of without the period
|
# ? Oct 20, 2015 18:39 |
|
kloa posted:That was it! My entire javascript career is a series of incredibly dumb mistakes, just glad I could actually help someone else for once!
|
# ? Oct 20, 2015 19:02 |
|
What's a good response in a technical interview for a javascript position when they tell you to do a specific kind of search and modify operation with an unsorted array and then to "convert it into a hash map." I was under the impression that since javascript arrays are objects and their indices are actually keys, a hash map is not a meaningful concept. Is it some kind on initiative test where you're supposed to call shenanigans, or is it pretty common to get interviewers that don't know anything about javascript since whiteboarding is more about general CS skills?
|
# ? Oct 21, 2015 05:08 |
|
my effigy burns posted:[...] operation with an unsorted array and then to "convert it into a hash map." I was under the impression that since javascript arrays are objects and their indices are actually keys, a hash map is not a meaningful concept. wikipedia posted:In computing, a hash table (hash map) is a data structure used to implement an associative array, a structure that can map keys to values. A hash table uses a hash function to compute an index into an array of buckets or slots, from which the desired value can be found. Arrays in JavaScript are only numeric: code:
code:
code:
|
# ? Oct 21, 2015 05:59 |
|
v1nce posted:Arrays in JavaScript are only numeric: Try setting x.wibble; arrays can have non-numeric properties just fine. (Array.prototype, which is an array, has a bunch of non-numeric properties like map and splice.)
|
# ? Oct 21, 2015 07:49 |
|
Or you could try reading all of my post.v1nce posted:And you can gently caress this up by treating an array like an object, but it'll still behave mostly like an array: It shows up in the keys, it gets iterated, but it doesn't add to the length, and it doesn't appear in the array itself. You're meddling with the Object formulation of the Array, rather than the actual array data structure.
|
# ? Oct 21, 2015 08:46 |
|
v1nce posted:Or you could try reading all of my post. I read your whole post. You can have properties on Arrays that aren't non-negative integers: they appear in keys and importantly can be used to retrieve values. They don't show up in toString output, but they don't appear in Object's toString output either! Array is specified to be Object with a different prototype, plus a magical length property that reacts to some keys (those that look like non-negative integers). Until 2008, when I split the implementation in Firefox to specialize dense storage of array values, AFAIK all JS engines implemented arrays as the same underlying structure as Object, including creating string keys for accesses and doing a hash or similar lookup. I don't know what "the Object formulation of the Array, rather than the actual array data structure" means, tbh. There is a good reason to not use Arrays as arbitrary dictionaries if you don't know the range of possible key names, but it's because of something Array does, not because of something it doesn't do.
|
# ? Oct 21, 2015 13:03 |
|
my effigy burns posted:What's a good response in a technical interview for a javascript position when they tell you to do a specific kind of search and modify operation with an unsorted array and then to "convert it into a hash map." I was under the impression that since javascript arrays are objects and their indices are actually keys, a hash map is not a meaningful concept. If I asked this in a javascript interview, this is how I'd expect it to go: code:
|
# ? Oct 21, 2015 13:16 |
|
Promise question related to flow control: Say I have a promise chain with a bunch of step functions, my code loooks likes this: code:
code:
|
# ? Oct 21, 2015 18:04 |
|
Knifegrab posted:Promise question related to flow control: Just throw an error when you want to get off the ride.
|
# ? Oct 21, 2015 18:54 |
|
Don't use errors for flow control, IMO. I would have the conditional either kick off a promise chain if it wants to do more work, or return otherwise. It also puts the definition of the subsequent promises subordinate to the condition on which they're predicated, which IMO is much clearer.
|
# ? Oct 21, 2015 19:43 |
|
Subjunctive posted:Don't use errors for flow control, IMO. I would have the conditional either kick off a promise chain if it wants to do more work, or return otherwise. It also puts the definition of the subsequent promises subordinate to the condition on which they're predicated, which IMO is much clearer. Yeah error for anything other than actual error reporting (and this is functional branching, it is allowed to be one or the other value) seems like a bad idea. I ended up just nesting a promise structure inside the promise chain, that worked best, though I am not in love with the solution it seems to be the best approach less I continuously pass the values to the next handlers and do endless checking therein.
|
# ? Oct 21, 2015 22:04 |
|
Knifegrab posted:Yeah error for anything other than actual error reporting (and this is functional branching, it is allowed to be one or the other value) seems like a bad idea. I ended up just nesting a promise structure inside the promise chain, that worked best, though I am not in love with the solution it seems to be the best approach less I continuously pass the values to the next handlers and do endless checking therein. What do you nerds think about using PostgreSQL with Node and Express and Angular? I know Mongo is poo poo (or so I've heard) so I'm looking for something else. PEAN Stack? Also, thoughts on http://docs.sequelizejs.com/en/latest/ ? Huzanko fucked around with this message at 01:58 on Oct 22, 2015 |
# ? Oct 22, 2015 01:54 |
|
Noam Chomsky posted:What do you nerds think about using PostgreSQL with Node and Express and Angular? I know Mongo is poo poo (or so I've heard) so I'm looking for something else. A lot of people seem to use sequelizeJS, but there are others like bookshelfJS. I'm also in the process of switching from Mongo to postgreSQL, but I haven't decided on a library yet.
|
# ? Oct 22, 2015 02:12 |
|
Odette posted:A lot of people seem to use sequelizeJS, but there are others like bookshelfJS. Thanks! Nice to know it's a thing that people do. I only ever hear about Express Node and such in the context of using Mongo, which I'm told is poo poo garbage, so that's kept me away from the stack. However, I'm a JS dev so I kinda want to build some Node apps, rather than go back to Rails again, or pick up something totally new, again, for my webapp needs.
|
# ? Oct 22, 2015 02:15 |
|
What about RethinkDB?
|
# ? Oct 22, 2015 02:28 |
|
Noam Chomsky posted:What about RethinkDB? As long as it fits your data model, you're fine. And unless you are trying to plan the architecture for a potentially large system... you're over thinking it. Especially if you are just going to be working on some personal apps. Pick whatever looks fun and get to work, stop malingering.
|
# ? Oct 22, 2015 02:38 |
|
Skandranon posted:As long as it fits your data model, you're fine. It's an app for a tabletop RPG I'm designing. I mean, I'd like to just go with Mongo since I've gotten reasonably familiar with it but I don't know if schemaless will hurt me in this kind of app. Also, I don't know much SQL.
|
# ? Oct 22, 2015 03:39 |
|
Noam Chomsky posted:It's an app for a tabletop RPG I'm designing. I mean, I'd like to just go with Mongo since I've gotten reasonably familiar with it but I don't know if schemaless will hurt me in this kind of app. I doubt Mongo will seriously hurt you there, just go for it.
|
# ? Oct 22, 2015 05:23 |
|
Skandranon posted:I doubt Mongo will seriously hurt you there, just go for it. Thanks! I've kinda been hand-wringing over it.
|
# ? Oct 22, 2015 05:46 |
|
Noam Chomsky posted:What do you nerds think about using PostgreSQL with Node and Express and Angular? I know Mongo is poo poo (or so I've heard) so I'm looking for something else. I use this minus angular. But node+express+postgres works wonderfully. I am not really familiar with angular JS, I think its a promise library? If it is I use Q instead. If its like Jquery I use jquery instead.
|
# ? Oct 22, 2015 08:56 |
|
Knifegrab posted:I use this minus angular. But node+express+postgres works wonderfully. I am not really familiar with angular JS, I think its a promise library? If it is I use Q instead. If its like Jquery I use jquery instead. Angular is a javascript framework for web apps. It's has a promise library built in and it is better than using pure jQuery for controlling the UI IMO. It's pretty nifty generating entire components of a page using a few lines of code. Example: You have an array of objects containing images and text you need to output to a list code:
|
# ? Oct 22, 2015 15:11 |
|
Angular is a kitchen sink MVC library. React is just a very efficient templating/DOM manipulation library that you could even use with Angular if you really wanted.
|
# ? Oct 22, 2015 15:25 |
|
IronDoge posted:Angular is a javascript framework for web apps. It's has a promise library built in and it is better than using pure jQuery for controlling the UI IMO. It's pretty nifty generating entire components of a page using a few lines of code. jQuery and Angular aren't even comparable. One is a library, with the original goal of making cross-browser JS consistent; Angular is an entire MVC framework.
|
# ? Oct 22, 2015 20:25 |
|
I think I will definitely be pursuing React and react routing in my next step of development.
|
# ? Oct 22, 2015 20:41 |
|
Knifegrab posted:I think I will definitely be pursuing React and react routing in my next step of development. Do it. React has been a pleasure to work with.
|
# ? Oct 22, 2015 20:51 |
|
I'm getting the mouse coordinates of an image. 0,0 starts at top left corner. Is it possible to get 0,0 to start at bottom left?
|
# ? Oct 22, 2015 21:15 |
|
stoops posted:I'm getting the mouse coordinates of an image. 0,0 starts at top left corner. No, that's not how it works. You can adjust your calculations based on the co-ords and the width/height, but you aren't going to get the browser to give them differently.
|
# ? Oct 22, 2015 21:27 |
|
You should also get over the math-nerd obsession with the position of the origin and get used to 0,0 being the top left of the image, because this has been standard in computer graphics since the dawn of time.
|
# ? Oct 23, 2015 00:17 |
|
Vulture Culture posted:You should also get over the math-nerd obsession with the position of the origin and get used to 0,0 being the top left of the image, because this has been standard in computer graphics since the dawn of time. Isn't OpenGL bottom-left?
|
# ? Oct 23, 2015 00:20 |
|
|
# ? Jun 5, 2024 19:38 |
|
Subjunctive posted:Isn't OpenGL bottom-left?
|
# ? Oct 23, 2015 00:25 |