Category "javascript"

Assign value only when key is a valid property of a type in TypeScript [duplicate]

I have a type, e.g.: type Output = { fieldA?: string; fieldB?: string; } And I have an object, e.g.: const input = { fieldA: "A", fie

How to prevent Jest from combining results?

I currently have two jest test cases the first one passes, but the second fails because its adding the sum of the previous case to that one test('Subtotal to be

What is the proper way to POST data using javascript fetch? [duplicate]

I am trying to get away from jQuery and start using promises and arrow functions. Try as I might, I can't seem to pass data to PHP using java

How To Find Out Where the Short URLs Point To with Javascript

I have created a short url, let say https://my.short.link/foo, that is pointing to https://my.other.website/bar. How can I retrieve this url with a javascript m

What is the function of this code in thumbnails: quot

What is the meaning of this code please? &quot;300:100&quot The code is in this line: <a expr:href='data:post.url'><img expr:alt='data:post.tit

How can I call a Powershell / Command Line Script using a BrowserAction in a FireFox WebExtension?

When the button is pressed, I want to get the URL from the current tab and pass it as an argument to the script. I know that I have to use browser.browserAction

Not able to Initialize Firebase APP inside script module in HTML

I am working on a minimal (proof of concept) project with Preact and Firebase. A single HTML file, bundler/transpiler free thanks to HTM as JSX replacement. Her

Why does partial application work when currying but not with .bind()?

I'm practicing partial application of a function, that is, fixing function arguments. I've learned two ways to achieve it: By currying the original function fir

Why getting firebase is not defined error?

Here's the code for the firebase.js file where I'm getting this error in spite of strictly adhering to the official documentation of Firebase. firebase.js impor

How to make a button move?

I'm going to make 8 buttons move down to the bottom of screen one by one but I have a problem here is my code : var i = 0; var j = 0; while(i < 7){ i++;

Why for in loop returns string instead of my object? [duplicate]

i have nested object: var obj = { nestobj1:{ title: "some 1 title", text: "some text" }, nestobj2:{ title

Variation: Find the object with the highest value in Javascript [duplicate]

In Finding the max value of an attribute in an array of objects there are many (great) answers that report the highest value in an array, but

Please explain the purpose of the bitwise or in this javascript function

I am converting a javascript function to java, and don't understand the purpose of the bitwise ors in the code below: (Math.tan(PHId)) ^ 2) - is this ensuring t

Nuxt.js using Vuetify and Vite causes "__createCJSModule__(...) is not a function" error

The problem: When creating a new Nuxt.js project using Yarn as the package manager and using Vuetify and Vite as build modules I get the following error in the

Uncaught ReferenceError: process is not defined after upgrading from vue cli v4 to v5

I'm working on an app where I've updated the frontend to use vue cli v5 from v4 and am getting a runtime error: Uncaught ReferenceError: process is not defined.

hello I am getting an error that shows up in discord modal it tells Something went wrong. try again discord.js

Hello I made a mail command which would take message from modal and send it to a mentioned user but it gives this error in modal window and does not log anythin

Navbar isn't turning red when I scroll down

I am trying to make it so when I scroll down in my webpage it will turn the navbar red. when you are at the top of the page it blends with the background but wh

Masonry JavaScript layout Disable and Reactivate problem with if

Can someone help me plz, I want to use masonry JavaScript when the screen is bigger than 800px and destroy/ disable it when screen is less than 800px. the probl

Put the cross on the top right page instead of the left

how can I put the cross on the top right side of my page? For now it appears on the left side. .close { vertical-align: middle; border: none; color:

how to apply numeric validation

I want to apply validation for integer but it's not working function fnAllowNumeric() { if ((event.keyCode < 48 || event.keyCode > 57) && ev