« first day (3200 days earlier)      last day (1742 days later) » 

5:28 AM
Hi
 
I have jQuery Question Please help me via this link chat.stackoverflow.com/rooms/196757/…
 
@Pritesh 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.
 
6:14 AM
hi any one out there i have a question on custom sorting based on javascript object.
this.cars = [
{ brand:"Facility 1", InstallationPriority: "1", RegionPriority:1, color:"Red"},
{ brand:"FAcility 92", InstallationPriority: "12", RegionPriority:0, color:"Red"},
{ brand:"FAcility 112", InstallationPriority: "0", RegionPriority:2, color:"Red"},
{ brand:"FAcility 82", InstallationPriority: "0", RegionPriority:3, color:"Red"},
{ brand:"FAcility 12", InstallationPriority: "0", RegionPriority:0, color:"Red"},
{ brand:"FAcility 42", InstallationPriority: "22", RegionPriority:0, color:"Red"},
 
I notice that when doing fetch e.g. fetch('/'), I get an object back where the content is locked and I have to do e.g. await fetch('/').then(response=>response.text()) I thought maybe it's locked because of something to do with promises, but I notice that I can do async abc() {return 123;} await abc() and it returns 123. So why is it that fetch returns an object with a locked field ? and it looks like the field is only accessible with 'then' i.e. not (await fetch('/')).text
 
I want to sort above object on property for example InstallationPriority . by acending and decending but in a custom way like . Ascending order
1,2,3,4,0,0,0,0

Decending order
if sort -0,0,0,0,5,4,3,2,1
 
@SeanCh i guess worst case scenario you write a sorting algorithm like in the old days.. bubble sort, or more efficient quicksort
and then look to see if you can customize it with the 0s
Or, there are some methods in some languages like C# that let you just pass as a parameter, the comparison that determines the sort. So usually like A>=B . but in your case it might be A>=B & A!=0 . or something like that, so if you find something like that you could experiment
 
1 message moved to Trash can
@Pritesh Please don't post unformatted code - hit Ctrl+K before sending, use up-arrow to edit messages, and see the faq.
 
I created the project In which I am using jQuery. In which nav is present. When I click to this nav then it displayed content. Now, I am trying to add this clickable nav to border-bottom effect using add CSS or class method. And First, nav is default clicked.

Below I am displaying my JQuery Code:

 $('.nav-collapse a').click(function () {
        $('.bb-wizard-page ').hide();
        $(this.getAttribute('datahref')).show()
    });
Okay
 
6:31 AM
@barlop I tried using partition function from lodash library and then also tried custom push function on javascript but push function does not append to end of array instead it is added it randomly into middle.
 
 
6 hours later…
12:06 PM
let obj1 = {
  value: "a"
}
let obj2 = {
  value: "b"
}


function change(obj1, obj2) {
    obj1 = obj2;
    obj2.value = "c";
}

change(obj1, obj2);
console.log(obj1.value); //a???? how????
 
@SamuraiJack The obj1 inside of the function is a difference reference from the one outside.
obj1 = obj2 changes the inner reference, but doesn't affect the outer one.
 
@MadaraUchiha because its executing in a different execution context ?
of function
 
No, because of how scope works.
let a = 5;
function foo(a) {
  a = 6;
  return a;
}

console.log(foo(a), a); // 6, 5
You didn't refer to obj1 from closure, you referred to the argument obj1
 
we are declaring new variable name obj1 when we say change(obj1) , right?
function change(obj1, obj2) is creating two new variables with scope limited to function right?
 
@SamuraiJack No, you're declaring the new variable because you named your argument obj1
function change(obj1, obj2) { // <--------- here
 
12:15 PM
isnt that what i said?
 
Consider this example with an argument name of anything other than obj1
let obj1 = {
  value: "a"
}
let obj2 = {
  value: "b"
}


function change(alice, bob) {
    alice = bob;
    bob.value = "c";
}

change(obj1, obj2);
console.log(obj1.value); //a
It's only confusing because you happened to call the argument obj1 too.
 
I know. I got it.
Thanks
 
12:35 PM
.
and in Mandara's example, obj2.value=="c"
i.e. when you change a field of an object from within a function, the effect continues outside
@SamuraiJack
But you can't change what an object points to in a way that it affects outside
things are passed by value in javascript, so the reference an object points to is passed/copied as a value.
so alice and obj1 don't sit on the same reference. They sit in different places in memory and each point to the same object before the first statement of madara's function runs.
You may think you have it but you might not. Try to understand it also when you make Madara's answer show console.log(obj2.value) as well.
 
 
1 hour later…
1:48 PM
are all packages always bundled with every page when using parcel? Or webpack also...
if I use a package in page hello.js
will that package also be downloaded when visiting page world.js
even if that page doesn't use it?
 
 
4 hours later…
5:32 PM
It's important to provide the page with the required CSS, otherwise the page will render with just the HTML then wait for the CSS to be injected by the client, causing it to flicker (FOUC). To inject the style down to the client, we need to:

    Create a fresh, new ServerStyleSheets instance on every request.
    Render the React tree with the server-side collector.
    Pull the CSS out.
    Pass the CSS along to the client.
    On the client side, the CSS will be injected a second time before removing the server-side injected CSS.
why do we need to send a CSS and then remove it instead of sending the right CSS already one single time?
and why do we render only one time with SSR?
When the server receives the request, it renders the required component(s) into an HTML string, and then sends it as a response to the client. From that point on, the client takes over rendering duties.
what does that actually mean?
 
 
1 hour later…
7:04 PM
I am using jsPDF to render images, svg and some html markup as pdf and that's working fine. But I cannot make css to work with it. Any pointers?
Btw, I am using html markup as string only because that's what I can use.
 
 
3 hours later…
10:31 PM
wohoo, your towc is a technical author:
(don't buy it. The book was long abandoned, and it seems that packt forgot to take it off the market. But my name is in there anyway so maybe that warrants me some internet points)
oh, don't amazon links get oneboxed?
 

« first day (3200 days earlier)      last day (1742 days later) »