« first day (4325 days earlier)      last day (618 days later) » 

1:45 AM
Can anyone please explain the difference between the following two?
 
 
6 hours later…
8:15 AM
@RaviJoshi on the left side the "Topic" is created after mount (when mounted() is called) on the right side it is created when the script is executed, so there might be a problem with stuff that is not initialized at this point
 
8:28 AM
@DamodaraSahu the difference between NFKC and NFKD is composite/decomposite form, they are both doing compatibility normalization, hence the presentation of U+0066 U+0066 for U+FB00 is the same
 
9:25 AM
I have
    div
      input
      label

how can I css target the label only when the input has focused? or do I need js?

ie

.sibling-input:focus  input:not([type="checkbox"]) {
  transform: scale(1.1);
}
 
See: :focus-within
Oh, no wait... is the label a sibling to input ?
In that case, just use input:focus + label {}
 
sibling yes
 
The + combinator will select the next immediate sibling, while the ~ combinator will select any subsequent sibling
 
9:44 AM
like this?

.d-input:focus +input:not([type="checkbox"]) {
  transform: scale(1.1);
}
nvm
works thanks
14 years and i never use that before
 
You're welcome. Depending on the context + and ~ can be very useful.
 
i was using tailwind, but for this i had to break out and dump this css on index.css

feels bad
 
Depends what you're used to, I guess... I used elements and combinators for years in CSS... then I started using BEM in 2018 and I've never wanted to write my CSS any other way, since
I have a javascript question...
I'm just getting my head around `.call()`
(Apart from just discovering that it doesn't work the same way with ES2015 arrow functions...)
I'm trying to get my head around why it's called .call()
If the object adopts the function... how is the function call-ing the object. I could understand .callFrom() where the function is being called from inside the object. How do I need to understand the verb call in this context?
 
call calls a method with a new this context
thats all
i almost never use it anymore
 
I'm learning all this at the moment:

I see that arrow functions basically make `.call()` unnecessary
So, it's only for function declarations.
 
9:57 AM
right
 
And I'm (gradually) understanding what .call() is for and what it does
 
make everythign arrow, done, js is patched
 
But... this:

`myFunction.call(myObject, 3);`

reads (to me) like `myFunction()` is _calling_ `myObject` and... that feels like me entering my house and describing it as: _"I called my house"_... where, if any calling happened at all, it should be _"My house called me"_.
Hence:

`myObject.call(myFunction, 3)`
But it isn't. So this is what I'm trying to get my head around.
 
myObject is the new this context
anything this. in thata func uses myObject
 
@Rounin-StandingwithUkraine myFunction.call() just means "execute a call on myFunction". The rest are the parameters for the call. Similar to how if you have person.eat(elephant) what you are doing is telling the person to eat and then you have the parameters for the eating.
 
10:07 AM
Thanks @VLAZ, that's helpful. I think the block I may be stumbling against, is that, not being a developer, I am lacking a fundamental understanding of what the verb call means in a programming context
 
It usually just means to execute a function.
 
Got it. Perfect. Thank you. That's what I needed.
 
So hello() would be described in English as "calling the function named hello"
 
Great that really helps me get my head around the implied semantics of myFunction.call(myObject, 3);
Additionally, I've learned this morning that: arrow functions in JS have no execution context
 
I don't understand what you mean by execution context. Arrow functions most definitely have one. But perhaps you mean something different.
 
10:17 AM
@Rounin-StandingwithUkraine how do i get the rule to stay in place if not focused and has content?
like how MUI does it -> it used js
maybe :placeholder-shown
 
10:40 AM
works, sweet
 
Good work, @SuperUberDuper
 
@Rounin-StandingwithUkraine did you mean they don't have this binding? I agree with @VLAZ, they certainly do have execution context.
 
@Rounin-StandingwithUkraine thx for the ukraine support, i spend a lot of time there
 
@VLAZ, @OlegValteriswithUkraine - Thanks - I need to correct my earlier assertion.
@SuperUberDuper - I have an MA in Ukrainian Studies (from a former life before I started grappling with web dev)
 
@Rounin-StandingwithUkraine NP :) the important part is that you understand what that implies. How you call it... hardly useful in contexts other than interviews
 
10:44 AM
@OlegValteriswithUkraine - yes, exactly that - I mean that arrow functions don't have a this binding
 
and yeah, it's certainly context they lack as this is a context object
 
On a completely unrelated note: I'm thinking about getting a license for WebStorm. It's 70 Euro for a year. Then each additional year is a bit cheaper (10-ish Euro down). It's on the expensive side for me mostly because I hardly write code (in a proper editor) when not at work. I mostly use TS playground or JSBin and similar to prototype stuff. Or directly in the browser console.
 
Re: "How you call it... hardly useful" - no, for me, it's essential - my background is in languages, linguistics, philology... a functional understanding is not enough for me, I feel uncomfortable if I don't have as full linguistic comprehension as I can muster
 
I use VSCode for larger projects. But I might give WebStorm a try - if I like it, I might stick with it. If not, 70 Euro is not THAT big of an expense.
 
10:48 AM
I mostly use Sublime Text 3 (force of habit) but I need to make the effort this year and start working from Visual Studio Code for all my projects. I love VSCode.
 
I have to add to the above comments of mine that technically, arrow functions have this binding, it's just lexical (meaning that it is locked at the time of defining it) as opposed to dynamic
 
@OlegValteriswithUkraine "have" is certainly correct. But might be more descriptive to say they inherit the this from their lexical declaration.
 
vscode sucks
webstorm better
 
So, they still have a this but it's not theirs
 
vscode is million ways to do things
 
10:53 AM
@SuperUberDuper Yeah, I find that aspect a bit annoying. With that said, it's still a really good editor. It's the best one I've used. Well, at work I use Rider (since we use C# anyway) and it also handles JS/TS pretty well. I've not tried WebStorm yet.
 
I can't find a way to y offset the text in an input

MUI does it with a input margin side another div, which i dont want to do - > major headache
 
VSCode has some weird configuration options some times. I remember having to jump through some hoops to enable ESLint autofixing files on save. You had to edit the JSON configuration file, since in the UI you didn't have an option to configure it properly. You had to disable something which wasn't exposed as a configuration option.
 
@OlegValteriswithUkraine - the best way I can describe my (optimal) approach to learning JS is like when Gant steals the incredible MiG-31 from the Sovs. But the only way he can control it is to..."Think... in Russian". (I need to not just flick switches and pull levers, I need to "Think... in Javascript") See: youtube.com/watch?v=ky-uzsw0kqw
 
ah i can just use padding cool
 
Hopefully, that is fixed now. It was some configuration incompatibility with the ESLint plugin and the general editor. With that said, those are relatively rare. And VSCode usually works quite well. Other editors I've used have had a lot more shortcomings. Brackets was rather good but poor support for extra functionality. Atom was more powerful was a pain to set up properly and keep it updated. Notepad++ is decent but not a lot of extras.
I've not tried using Vim, I suppose there is a lot of neat features it has but...well, it's Vim.
 
10:58 AM
I dabbled with Vim last month (first time)
My thinking was... if it's survived this long, there must be something good going on
My tentative conclusion was that the fork NeoVim is probably the best option:
https://github.com/neovim/neovim/releases/
But I also looked at gvim:
https://www.vim.org/download.php
 
@Rounin-StandingwithUkraine did you manage to exit from it?
 
11:44 AM
so many edge cases trying to replicate MUI input even without the ripple or caption
im trying to figure out how with css i can tell the label that overlays the input not to prevent the input focu
so far:

    <div class="w-full h-[48px]">
      <input
        required={required}
        type={props.type}
        onchange={props.onchange}
        onkeyup={props.onkeyup}
        class={`d-input h-full appearance-none border-2 border-gray-200 rounded w-full
  text-gray-700 leading-tight focus:border-blue-500;
  focus: border-blue-700 pt-[12px] pl-[30px]`}
        placeholder=" " /*allows us to test for this and avoid using js to animate the label*/
      />

      <Show when={props.label}>
ah pointer-events : none;
 
@VLAZ yeah, a perfectly technical definition of what happens is that it resolves to a binding in a lexically enclosing environment during evaluation
 
any way to tell a transfrom to use origin-left but ignore the padding of the elment?
ie if label is padding 30px, and i scale it to 0.8, i only want to scale from the point of the left text, not the padding also
nvm , just used left 30
 
@Rounin-StandingwithUkraine is that a Firefox reference? :) unfortunately, I have neither watched the adaptation nor read the books. IMO, JS doesn't require "thinking in it", more like keeping in mind its roots (Scala for example). It's much easier if it's one's first language (as was in my case) - many that start to learn it with backgrounds in other langs struggle 'cause the terms look similar but function differently under the hood.
I don't envy any Java programmer trying to switch to JS, for example :) That's a mind-bending experience
@VLAZ I stopped using the settings UI as soon as I understood I can just edit JSON. The UI certainly has... problems
 
12:01 PM
@OlegValteriswithUkraine Eh, changing from your first language to another usually is.
But then again, Java -> JS tends to be a bigger jump than, say, Java -> C#.
 
@VLAZ that's funny
eh
did not have gotten that trouble, but the blog pointed out on something crucial: users gets dropped into it without knowing it. Gotcha blame git for that
 
But I guess Java -> Python would also be a rather large jump. Even more so with something like Java -> Prolog or Java -> Haskell. Switching context for how things work in general is always unusual. The first time, at least, once you've done it once, it's not as difficult.
 
I got a one hour vim session in my first bachelor year, as part of Linux OS course. That really helped me
@VLAZ did you have heard of jython?
it was popular a while ago and my company has some legacy projects using jython. Every dev did not like to work on defects linked to that project. So far I did not have to touch it
 
@KarelG Same. We also had instruction in how to use Vim. It's basically press **i** to enter edit mode, press Esc to exit it. Use :w` to save, :q to exit, :wq to save and exit, and :q! to exit without saving". That was the entire thing.
@KarelG I've heard of it but that's about it. I know it's Java related. Probably works on the JVM, I'd guess.
 
@VLAZ probably the easiest jump to Python is from JS itself. At least I felt this way :) It's, like, "oh, so it's like it, but saner?"
 
12:13 PM
py saner?
PYTHON IS SANER?
 
Don't let me call Batman to explain it to you.
 
the logo of Python ain't a lie. It's really a snake, eventually you gets wrapped and wriggled beyond oblivion that you wish you were at javascript
 
eh, dunno, I find it quite elegant compared to what I have to go through with JS
 
@OlegValteriswithUkraine I personally feel getting a good understand of JS made it easier for me to understand a lot of other languages. Since it mixes both OO and non-OO concepts, it allows for various modes of abstraction to be used. And this made it easier to also understand the true mechanisms behind these abstractions. I suspect Python can also be used that way. Multi-paradigm languages can in general. Or probably using languages with different paradigms.
 
then you still have to experience that ... 😉
 
12:19 PM
@VLAZ same here - for the most part, I do not regret starting with JS (just wish I plunged into TS sooner), its mish-mash of approaches really helps indeed
 
I did some Prolog during university and it's also an interesting way to program. I do want to revisit it at some point. I barely got it back then. But for example, we had an assignment that is to give route information for how to navigate the Londom metro. If you want to get from one stop to another, which line you have to get in, in which direction, and where you need to change. The metro stations with connections were provided. The whole application takes like 10-20 lines of code.
Prolog is quite powerful in traversing graphs.
My submission was...uh, not great. It got you to the end but the route wasn't the best. Like if you want to go from station A to B and they are next to each other, it might get you to go in the opposite direction and change three times. I finally got how to do it better...the same day as the submission...also after it was handed in. IIRC, I think I needed literally two lines of code.
 
haskell and prolog shares the same concept: predicate logic
like fibonacci in prolog is ...
f(0, 1) :- !.
f(1, 1) :- !.
then last
f(num, out) :-
f(num - 1, out1),
f(num - 2, out2),
out = out1 + out2.
90% sure if my memory is correct on the operators
!! google try it out prolog
 
kek compilation error ;_;
 
12:40 PM
does anyone know how to make browser handle the download progress while downloading the file through js blob method
 
@VardanaBhanot 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.
 
 
2 hours later…
2:18 PM
@hacksrinja 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
@hacksrinja 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
@hacksrinja 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
1 message moved to Trash can
 
2:31 PM
o/
i haven't seen your previous messages, but, generally, people try posting code and text in the same message
that doesn't work here in chat
post your text, then post your code, two messages
just ensure the code is indented
 
    Why console.log(res.category) shows undefined? [closed]
    Asked today
    Modified today
    Viewed 37 times

    -2


    Closed. This question needs details or clarity. It is not currently accepting answers.
    Add details and clarify the problem you’re solving. This will help others answer the question. You can edit the question or post a new one.

    Closed 3 hours ago.

    In below code when console.log(res) i get same as what i have got at console.log(req),but when i try to fetch res.category it shows "undefined" unlike req.category why??
 
@hacksrinja 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
 
  exports.read=(req,res)=>{

        console.log(req);//shows all requested data
        console.log(res);//shows all requested data
        console.log(req.category);//shows particular category object data
        console.log(res.category);//shows undefined

        return res.json(req.category);

    }
 
1 message moved to Trash can
 
because, it shouldn't exist on res
 
2:33 PM
@KevinB ok
 
res is the response object that you use to respond to the request
 
ok but i canot run it in console it shows undefined
 
you mean on the client?
on the client your json response will simply be a string that is the value of req.category
 
when i do console.log(res)?
 
?
depends on what res is
you haven't shown any client code
 
2:36 PM
no in server
 
on the server res should be a response object
it'll have methods like .json and .end
 
ok
but when console.log(req) it shows req data
 
right
that's its purpose
req is the incoming data
res is the object that has methods you can use to respond with data
 
but when i console.log(res) it also shoes same data but when want to fetch the particular category object i cannot do it
 
res doesn't hold data
 
2:38 PM
but when i console.log(res) it shows data
 
it shows you properties of an object
it's an object, so that makes sense
 
okk its only properties of req??
 
but it shouldn't contain the data you're trying to respond with
it'll contain the properties that response objects should contain
which differ from request objects
 
okkk i understand res contain only whatever req is contain not actual data,am i right?
 
no
req represents the incoming request
 
2:41 PM
yes
 
it'll have headers, properties added by middleware like category, and any data that the client sent to the server
 
req?
 
yes
 
ok
res?
only properties
 
res i the response object, it'll also have headers for what will be responded with, and it'll have methods for ending the request and sending a response
 
2:44 PM
ok but when i console.log(res) it shows same as req
why?
 
you've said it doesn't
res doesn't contain category
you should also see extra properties on res that don't exist on req
like .json, .end, .text, .html, etc
 
i want to say when i console.log(res) it shows all properties like req include category, but when i console.log(res.category) it shows undefined??
 
i think you are mistaken
 
where u think?
 
is it supposed to? last time I checked, instances of the Request class (neither, obviously, instances of the Response class) don't have that property. I assume you want to get those from request body
 
2:50 PM
it is possible for middleware to create such a property, which is what i'm assuming happened in this case, but who knows
(ideally the person with the code would know)
 
can i give screenshot of my code or cmd prompt?
 
@KevinB yup, or that, I suppose
 
exports.categoryById=(req,res,next,id)=>{
    //console.log(req);

    Category.findById(id).exec((err,category)=>{
        //console.log(id);
        //console.log(category);
        if(err||!category)
        {
            return res.status(400).json({
                error:"category does not exist"
            });
        }

        req.category=category;
        //console.log(req.category);
        next();
    });

}
router.get("/category/:categoryId",read);
router.param("categoryId",categoryById);
this is the read function
exports.read=(req,res)=>{

        console.log(req);//shows all requested data
        console.log(res);//shows all requested data
        console.log(req.category);//shows particular category object data
        console.log(res.category);//shows undefined

        return res.json(req.category);

    }
 
3:17 PM
@OlegValteriswithUkraine i pasted all related codes
 
why do we need font-x.ttf varients when we have css font weight?
 
3:44 PM
@hacksrinja aha, I see, a middleware sets the property, a sec
oki, so, is this an express server?
nvm, this makes sense now - the middleware sets the property on the req object. It doesn't automagically become available on the res object. With the current setup, you'll have to use req.category
if this is an express server, you can set the property as a local on res via res.locals.property_name
 
4:10 PM
Yes express server
 
5:03 PM
@OlegValteriswithUkraine how?
 
 
2 hours later…
6:43 PM
@hacksrinja res.locals.property_name = property_value
but...
not sure what you expect that to do
 
 
4 hours later…
10:31 PM
 

« first day (4325 days earlier)      last day (618 days later) »