I have a array of mongodb object-id and i want to sort them in such a way that similar IDs are next to each other example : Input : var array = [“507f191e810c19729de860ea”,”00000020f51bb4362eee2a4d”,” 507f191e810c19729de860ea”] Output : var array = [“507f191e810c19729de860ea̶…
Tag: javascript
React Using addEventListener(“scroll”, function()) and useState shows no transition
I want to change background color of navigation gradually with transition like this Article.js Article.css When I run these, class name ‘active’ is added to the [div] but its background color is changed quickly from rgb(248, 249, 250) to rgb(255, 255, 255). I think this is because addEventListener…
middleware.js in nextjs doesn’t work at all
(Next v.12.2.3) No matter what I code, pages/middleware.js seems not running at all! I wanna redirect uppercase urls to lowercase urls. what should I do? Answer The documentation says: Create a middleware.ts (or .js) file at the same level as your pages directory So it shouldn’t be inside pages/, but in…
PrimeVue DataTable Column Sort not Working with Date
I have a DataTable, as listed below: initialDate and finishDate are both data fields that are pulled from an API call, and will look something like this: “08/21/2022 11:43:12” When I attempt to sort these columns, they do not sort by the actual date (which is what I need), but just the first numbe…
Target classes inner HTML based on URL parameters
I asked a similar question about customizing the inner HTML of span id’s, and although it worked perfectly, I’m looking for a solution that will let me use multiple instances of the same target on the same page (doesn’t work with id’s since they need to be unique). Right now, I am targ…
Capture value from an input with svelte
I’m trying to capture the value of an input using the svelte framework When initializing the local environment I already get the following error in the console: Uncaught TypeError: Cannot read properties of null (reading ‘value’) Visual Studio Code marks the code snippet .value when I try to…
Why can’t we destruct objet and in order to create new variable : JS
Can someone explain me the reason why : Will set my variable to : And not Or even undefined why taking this choice ? I’m curious ! Answer The value of an assignment expression is the right-hand side of the assignment. So {hello, world} = param performs a destructuring assignment to hello and world, but …
Encrypting data using query in Node.js and MySql
Is it safe to encrypt the data posted in MySql using query in node.js? I tried something like this and it works pretty fine in terms of encryption but I don’t know exactly how safe it is, I am pretty much a begginer in this area. Answer Let’s say I wanna encrypt the password so it could be safe fr…
How do I set a route in hash mode with params with Vue Router 3 (Vue 2)
Currently, my Vue router is using hash mode for my router and I am looking for a way to pass parameters when generating links to another component. so far I came up with this: this is what it currently looks like in my Markup: I am passing down the article id into the link so that when the user clicks
Angular – How to link several typescript files with one template file?
Imagine if you have a typescript file like the following one: I would like to outsource these methods. However, the classes must inherit the properties from ProductAlertsComponent, as it would operate on/with them. So, in a separate file, I would do the following logic: But the template angular file (product-…