« first day (4276 days earlier)      last day (657 days later) » 

3:17 PM
what distinguishes a constructor function from a non-constructor function?
 
3:31 PM
@DimitrisPapageorgiou not much. Essentially a constructor function you can (and probably should) call with new and a non-constructor function you shouldn't (and maybe even cannot) call with new.
 
it's safer to define what is not a constructor function. Mainly, if one returns a primitive, it is definitely not. If it does not make use of this, it is likely not. Other than that, there is a difference in usage as outlined by @VLAZ above
If you see FunctionName.prototype.propertyOrMethodName = ... or FunctionName.staticPropertyOrMethodName = ..., it is also likely to be a constructor
 
^ also what Oleg said.
Callable objects (or "functions", if you will) that cannot be called with new are arrow functions and shorthand methods. Using new with them throws an error.
||> foo = () => {}; new foo
 
@VLAZ 'TypeError: foo is not a constructor' Logged: [ ] Took: 70ms
 
well
 
||> obj = { short() {} }; new obj.short
 
3:35 PM
@VLAZ 'TypeError: obj.short is not a constructor' Logged: [ ] Took: 0ms
 
one is a constructor function and the other isn't
 
A function that can be called with new but isn't a constructor function would be anything that doesn't return instances of itself. Which happens if the function return a non-null non-primitive
||> function Hello() { return {hello: "world"}; }

const obj = new Hello();
obj instanceof Hello;
 
@VLAZ false Logged: [ ] Took: 34ms
 
@VLAZ oh, yeah, and arrow functions and shorthand methods, slipped my mind
 
And if a function doesn't return anything explicitly, calling it with new will technically produce an instance of the function but that's not always the intention of the function.
||> function Foo() { console.log("log something"); }

const obj = new Foo();
obj instanceof Foo;
 
3:40 PM
@VLAZ true Logged: [ '"log something"' ] Took: 0ms
 
So, the function is executed, you get an instance of it but it's not really intended to produce instances. It's just a void function.
 
 
2 hours later…
5:22 PM
as a sidenote: functions that do not return anything are called void functions???
as a sidenote: functions that do not return anything are called void functions???
 
5:45 PM
i've never heard of void functions
It's usually to best to just call functions functions
 
anyway...
2
 
 
1 hour later…
7:04 PM
hi
 
o/
 
I have a strange occurrence in my code and Id just like to find out if anyone has come across something similar
 
interesting
 
ok, my image gallery works if I alter something in the code then save it (something that doesnt effect the actual code) but when I go to a different page or refresh it it stops working. Does anyone know why? Heres a link to my code stackoverflow.com/questions/72831452/…
 
err, i'm not gonna touch that
i don't mess with combinations of react + directly touching the dom
 
7:19 PM
ok, thanks anyway
can I ask why?
 
because when react detects a change in state it rerenders the dom, causing all of your work to need to be redone, with each rerender
 
ok interesting
 
(which could be causing your problem)
i didn't mean to cause any offense, just not an area i'd want to mess with, :p
 
so, maybe if I create a loop?
 
well, in your case, you seem to be just adding event listeners
which could be done within your return( block
similarly, you can control which image is active with your state, rather than directly
 
7:25 PM
so, if I post another question asking that, I may get an answer
thanks for pushing me in the right direction
 
i'm not sure on that specifically as a new question, might be a bit too many topics to cover in one. but i'm sure there's a valid question there somewhere
the gist of it is, if you need x to change when y happens, x needs to be rendered based on state, and y changes the state
following that rule, you'd almost never need to directly access the dom
 
 
2 hours later…
9:04 PM
@LuminousButter as a quick aside, adding event listeners in a loop is considered to be an anti-pattern (I am guilty of it myself for one-off projects where delegation is too much work, though) - it is better to delegate to the parent element, let the even bubble up the DOM, and check that target on the event is the element you need to process.
 
I'm trying to get a regex to match the guid in a url but am awful with regex. What I've got:
s = ' hi tella.video/haste-demo-usehasteio-8uch '
re = /\(https:\/\/tella\.video\/(?<id>[a-z0-9\-_]+)/gi
re.exec(s)
but that doesn't match--anyone see what I'm missing?
 
i don't understand the question, but that might be on me
grab everything after / that is part of the guid?
What's the ?<id> for
 
I don't work with React often, but what you are doing, @LuminousButter, does not seem idiomatic React to me, and it feels very off to try to add listeners before the component is rendered (that might actually be the problem). Have you tried the idiomatic way of adding listeners?
 
yeah, there's a way with regex to capture haste-demo-usehasteio-8uch and have it appear in the regex result
but my regex doesn't match at all at the moment!
 
@DimitrisPapageorgiou Yep. "void" is pretty standard terminology for those.
 
9:14 PM
are you sure you are trying to match a GUID, @duhaime? guids are 128-bit globally unique identifiers, and it does not look like one
 
by GUID I mean Globally Unique ID
there exists a bijective hashing function that converts these tella ids to version 4 guids, I'm sure
 
oki then - same question as @KevinB, what's <id> for here, is it a placeholder for a real thing?
 
@OlegValteriswithUkraine Named capture group
 
The regex has \( in the end and that's wrong. The URL in the string doesn't start with an open bracket
Either the sample string is wrong or the regex needs to not try and match an open bracket
 
9:19 PM
without it it obviously does seem to match
so... maybe just a typo?
 
Yes, either in the regex or in the sample string. One of the two is wrong. But most likely the regex.
 
huh, on an off-note, I can't even recall the last time I used a named capturing group in an expression
 
It's fairly new. I don't think I've written a real regex since it was introduced.
 
didn't even recognize the syntax until you mentioned it
 
Actually, I remember - I have had to write regex but not with capturing groups.
 
9:22 PM
what's a capturing group
 
the named ones or are you asking ironically?
so... @duhaime I guess @VLAZ is correct - I don't see a reason why would it not match apart from the starting escaped opening parenthesis. Maybe that's the problem?
otherwise, it works perfectly fine
 
@RowanParkinson Please don't post unformatted code - use the up arrow to edit your post, then hit Ctrl + K to format the code in that post. See the faq. You have 25 seconds to edit and format your message properly before it will be removed. Please separate code blocks from your actual question. Put your question in 1 message and then your code in a 2nd and format it.
For posting large code blocks, use a paste site like like gist.github.com, hastebin.com, pastie.org or a demo site like jsbin.com
@RowanParkinson Welcome to the JavaScript chat! Please review the room rules. If you have a question, just post it, and if anyone's free and interested they'll help. If you want to report an abusive user or a problem in this room, visit our meta.
1 message moved to Trash can
 
generally, in chat, you want to post things in separate messages
code blocks in a message of itself, your question in another, etc
it doesn't format mixxed text and codeblocks properly
 
9:38 PM
 
wait so I'm confused, how should the regex be declared in re = form?
 
@duhaime Without the firsts \(
 
ninja'd :) Yeah, ^^^
without it, seems to be fine
 
ah, incredible :) Thank you
 
9:42 PM
Who are familiar with Angular here? I want to retrieve a collection of query strings and assign them all at the same time to a property defined in a service component. The relevant code is given here: gist.github.com/pstricks-fans/a4b6497461d210eb18c9ea52d37eb6e3
 
yea, looks like you just had a typo there - was there a specific reason you wanted to include \( at the start? Looks like maybe the regex was designed to match on Markdown-formatted links [label](url), which would explain the leading opening parenthesis, @duhaime
 
lol, I was adapting another regex but I haven't written regex since my perl days like a decade ago
 
I forgot to make my gist above public. Fixed.
 
ah, heh, happens - it's easy to miss something like that, @duhaime :) and then stare at the line for too long.
 
I wish this chat had emoji reactions so I could give a :thumbs_up: and a :smile:
 
9:47 PM
oh, an off-note, you don't need to escape - in that position of a character class, but I guess it does not hurt to signify that it's not a part of a range
 
🚽
 
@duhaime you can, but not via chat, yeah πŸ˜…
ah, reactions, oops, sorry
 
i have some support for :emojiname: through an extension
for what isn't there, there's win+.
¯\_(ツ)_/¯
 
:man_shrugging:
 
I presume @duhaime meant reacting to messages - yeah, one can only star / unstar them
 
9:51 PM
that's what the reply tool is for
 
thanks again y'all, have a good day!
 
chat hasn't been updated, like, at all here since 2016 if I recall correctly
 
other than small insignificant stuff
like fixes to all the things the stacks update on SO Proper has broken
 
@duhaime you too! Credit to @VLAZ as they spotted it first
@KevinB ah, well, yes :) Search in the communities dropdown is still borken, btw
 
@OlegValteriswithUkraine πŸ™πŸ™reactions for chat πŸ‘πŸ‘πŸ΄
 
9:55 PM
@VLAZ funnily enough, it's the only time where I'd be O.K. with them - not when SE tried to add those to the Public Platform...
@RowanParkinson not an Angular SME, sorry [in case you are wondering why you are being ignored]
 
My PC is just too slow atm to open additional windows
running an android build
can only do so much on one core
 
heh, you really need a new one
 
10:14 PM
@OlegValteriswithUkraine No problem. By the way, what is SME?
 
ah, just a slang term around here for Subject Matter Expert, one with relevant knowledge
 
@OlegValteriswithUkraine Ok. THanks. Very good info.
 
well, you won't see it often unless you are on Meta :)
 
10:30 PM
take this with a grain of salt, but maybe subscribe to params and just Object.assign it to this as it is a record of key-value pairs since it seems that keys are the same (well, apart from UpcomingReleases - upcomingReleases, but I assume it's a typo)?
after reading the docs, I am unsure if ParamMap (that's why I proposed to use params [on an off-note, looks like it was considered for deprecation but there aren't any plans to do so now]) is iterable that could allow you to get all keys and values at once, it seems to only have getAll method that only returns values only which looks of dubious use to me
or would a single but batched update via Object.assign and just one subscribe to the observable params provides still be considered an error-prone way in your use case?
 

« first day (4276 days earlier)      last day (657 days later) »