Category "javascript"

Check if string not in array in javascript

Yesterday I asked a question and, "with a little help from my friends" got my little javascript working. This one: <script type="text/javascript" > fu

Dynamically get value of specific element from list of elements with same id

So I'm trying to make a star rating feature and I'm stuck on setting the value dynamically from a variable. I don't want to make it so that the stars are intera

Drag an Element as a window

I have an element that contains a couple of elements and I want that while clicking on the green header of the element it will be dragged with the mouse movemen

VS code - How to remove quotes from keys only but value remains

What extension or shortcut will format a JavaScript object's keys without using quotation marks? I saw this in a presentation: They Pasted the example in A) bel

How do I prevent an event from triggering during a GSAP animation?

I have a GSAP animation like this: window.addEventListener('keydown', ()=>{ GSAP.to(this.box, { x: this.box.position.x + 4, duration: 1, }

Converting a splitted objects of object to array of objects

I have this form of data coming from an API and I want it to convert into different structure in JavaScript . [ { "1": { "id": 1, "coinname":

Why can I add named properties to an array as if it were an object?

The following two different code snippets seem equivalent to me: var myArray = Array(); myArray['A'] = "Athens"; myArray['B'] = "Berlin"; and var myObject =

How to upsert object in Mongoose Array?

I want to edit an array with mongoose, if the object id already exist in the array, then it will create a new one, and if it exist, it will update. My code: con

Using ImmerJS to update child (by id) within a parent (by id)

How do I update the content of child12 using immerJS const [fields, setFields] = useState([ { name: "Parent 1", id: "parent1", child

ReferenceError: "_" is not defined

recipe = new Recipe(_.pick(req.body, ['name', 'tag', 'recipe'])); await recipe.save(); }); error: recipe = new Recipe(_.pick(req.body, ['name', 'tag

how to use a 'change' event on a 'number' input to change the quantity of a product in a cart page in local storage and also in the DOM with Js?

Please can you help me? I am doing an exercise on the creation of a dynamic e-commerce site (API and JavaScript) and I am stuck on my shopping cart page which m

How can you read POST data from a javascript XMLHttpRequest in Golang?

Here's the javascript function called: function cwk_submit_form() { var form = document.getElementById("FORM_ID") var XHR = new XMLHttpRequest(); con

How to inverse modify value of a prop

I've got a doubt regarding if there's a way in Vue to do the same as a prop but in the inverse way. Let me explain a bit better, so for example, I've the follow

Dropdown menu code not quite right on mobile

I have built a menu on this page that is live: https://boys-cry.com/ and it was working fine until I added the mobile background content on a different section

How can I force safari to enable my website javascript?

Recently I've got feedbacks from collegues and friends that some features of a website of mine doesn't work on Apple devices. With some research, I found out th

How can I simplify a nested object which has a lot of repetitions?

All these three objects have the exact same property and values. Is there any way to simplify the code and make it shorter? const MyMap = { 'myObject': {

How to post data to API in jQuery DataTable ajax?

Hi all I am using jQuery DataTable and performing server-side pagination and sorting. I am stuck at one place, I am having API that is of type POST, so I need t

What is the scope of variables in JavaScript?

What is the scope of variables in javascript? Do they have the same scope inside as opposed to outside a function? Or does it even matter? Also, where are the v

Discord js 13 button edit permission channel

When a person sends my command, a channel is created that only they have access to. Also, when creating a channel, a message is sent with the "accept" button, w

Decrypt AES 256 CBC using crypto-js

i have the following key to decrypt erUF9SRCNQZPCBezVGzYYnUVgwAKZTvXzS5Zhgw6B/4= into "54545fwfwefweffvfdv", I tried searching for similar question but the lack