I don’t understand why navigator.share() is giving me an error even though my website meets all of the requirements listed on MDN (has HTTPS and supported by the browser). The following code gives an error when I click the button: What am I doing wrong? The website is served over HTTPS and my browser su…
Tag: javascript
Can anyone explain to me this syntax in JS w/ React “{posts && posts.map((post)=> ( “
I’m new to JS and React and i’m currently working on a project using React. The project in question is a social media app where you create posts. I wanted to use fetch to get a list of “posts” and then use react to format them. I was able to get it to work from a post online, however I
How to detect a query param appended to URL using pure React
I have an injected external widget in my React application that have some links and when clicking in these links a query param is appended to the URL. Imagine something like this: base url: http://localhost:8080/ url after adding the query param: http://localhost:8080/?shouldOpenModal Is there any way to dete…
React.js JS Sending Array as a property to an element turns the array into an object
I’m attempting to understand why sending an array as a prop to another element transforms it into an object with a value of the array but I would like some help understanding the why and whether it is a universal JavaScript ‘quirk’ or if it is to do with React and props. The next paragraph i…
How to setup a Shiny app designed with Golem that uses a htmlTemplate and links to an external JavaScript file
I am trying to understand the required architecture of a Shiny Golem app that utilises a html template and invokes some basic JavaScript on the press of a button. I think that I might be placing the index.html file in the wrong location, and I have not had success on invoking the JavaScript addEventListener o…
How to sort arrays of array, sort by first then by second then by third then by …n th element, in generic way?
For example, if I want to sort arrays of an array, which the first element is min, then the second element is min, then the third… I can use sort to do it: Array with 2 elements Array with 3 elements: How about array with 3,4,5,…n elements? I think this solution is not good enough because it needs…
Making a analog clock by using html canvas
Below is my preliminary Javascript code for making a analog clock. My main problem is I don’t know how to clear the “previous second lines” on the clock surface: I have tried to use “ctx.globalCompositeOperation = “destination-over”;”, however not successful: Could yo…
javascript: How to trigger an if statement when a variable equals a number in an array? [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 6 months ago. Improve this question Basically what I have is an array with these numbers: var songTimer = [0,12,49]. What I wan…
How do I get the content of another child from a child element of a div?
I am making a to do list app and when the user presses the delete button, the list item should be removed from the list on the page but it should also be removed from the tasks list variable, which is a list of objects, containing a task and done property. The delete button can be used access its parent
Prompt Repeats Twice When Page Renders (Undesirable) React.js JavaScript
When I have a basic prompt setup such as or The prompt repeats itself twice when the page loads. I only want this to happen once. I tried initializing the prompt with a loop without useEffect and I get the same results. When I try to initialize the prompt with a loop inside useEffect the prompt only shows up …