Latest Questions

Get Answers to Your Coding Questions

10
Votes
Published 15 Apr, 2022
Javascript - I am getting RangeError: Maximum call stack size exceeded error in Javascript

As you wrote yourself, "Repeat the process until the number equals 1 (where it will stay), or it loops endlessly in a cycle". In your implementation, fn calls itself infinitely. In the process, the ja...

315
Votes
Published 15 Apr, 2022
Javascript - Check if a value is an object in JavaScript

UPDATE: This answer is incomplete and gives misleading results. For example, null is also considered of type object in JavaScript, not to mention several other edge cases. Follow the recommendation be...

1851
Votes
Published 15 Apr, 2022
Javascript - How can I remove a specific item from an array?

Find the index of the array element you want to remove using indexOf, and then remove that index with splice. The splice() method changes the contents of an array by removing existing elements and/or...

14
Votes
Published 15 Apr, 2022
Javascript - Find unique node number given x and y coordinates

This is a fairly straightforward 'zip' with an added map of previously seen points, here tracked in an object keyed by the JSON string of each point, and retrieving/setting the next id using logical n...

74
Votes
Published 15 Apr, 2022
Javascript - Testing objects for ancestor/descendent relationship in JavaScript or Jquery

In jQuery ancestors using jQuery objects I suggested if ($(obj1).parents().index($(obj2)) >= 0) { // obj1 is a descendant of obj2 }

37
Votes
Published 15 Apr, 2022
Javascript - Send messages between apps within same browser window

The parent must dispatch the message from the window of the target (child process, iframe in your case) not from the window object of the parent: const child = document.querySelector('iframe').content...

60
Votes
Published 15 Apr, 2022
Javascript - Advice on Javascript Promises script

It looks like this is the section that's causing problems: for(url of urls) { p = p.then(() => fetchOne(url)); } Here you're creating a global variable url, and since it's running asynch...

102
Votes
Published 15 Apr, 2022
Javascript - Redis Command To Sort Keys

Redis returns keys, using KEYS (don't use it in production!) or SCAN, unordered. There is no "fancy" API to return them sorted but you can do it in the client application.

74
Votes
Published 15 Apr, 2022
Javascript - Using reduce() to find min and max values?

The trick consist in provide an empty Array as initialValue Parameter arr.reduce(callback, [initialValue]) initialValue [Optional] Value to use as the first argument to the first call of the c...

90
Votes
Published 15 Apr, 2022
Javascript - Remove Specific HTML Component After Successful Response With JavaScript Fetch API

You can use the closest() method for finding the image componenet closest to the button returned by e.submitter. const forms = document.querySelectorAll('.upload-form-js'), uploadDetailsComponent...

23
Votes
Published 15 Apr, 2022
Javascript - Configure Next Js For Images For External Domains

You are supposed to export a single configuration object. First, Install 'next-compose-plugins': npm install --save next-compose-plugins Import it: const withPlugins = require('next-compose-plugins')...

67
Votes
Published 15 Apr, 2022
Javascript - auto fill form without id tampermonkey

I personally prefer to use jQuery over pure javascript in tampermonkey because it gives me more control such as loading the script when the DOM is ready. i.e. wrap the function in a $(document).ready(...

12
Votes
Published 15 Apr, 2022
Javascript - JavaScript onclick event handlers not functioning properly

There's not really a "ready" event like that. If you want to do things at what's commonly thought of as the "ready" point, you'll need to use a framework. Otherwise, you can use "onload" instead of "r...

62
Votes
Published 15 Apr, 2022
Javascript - How can I send data via Websocket from a VSCode extension

used ws package, which sadly is not in ES6 module format but otherwise does its job.

5
Votes
Published 15 Apr, 2022
Javascript - Component not updating after useEffect call

Since you call get(), you're only getting the data once. If the data is updated after that, your setCloudUserMachineList won't be updated. If you want to listen for updates to the data, use onSnapshot...

101
Votes
Published 15 Apr, 2022
Javascript - Nuxt image keeps breaking on page change

You can check my previous answer here: https://stackoverflow.com/a/67705541/8816585 This may help export default { publicRuntimeConfig: { baseUrl: process.env.BASE_URL, }, } Otherwise, this c...

74
Votes
Published 15 Apr, 2022
Javascript - Yet again, CSS being problematic again

To fix header you need to set its height to fit content, so it will be over your grid even if you change it later: .headerDisplay { width: 100%; height: content-fit; /* previous: 76.8px */...

58
Votes
Published 15 Apr, 2022
Javascript - array.find(name) returns TypeError name is not a function - Javascript

This is because find takes a function as its argument—not a string. If you wanted to use it here, you'd need to supply a function, such as (s) => s === 'BananaBoat', as the argument. The function you...