javascript Questions

12

I need to set an Authorization header to an HTML5 EventSource. As Server Sent Events seems to be disused since Websockets appeared, I cannot find any useful documentation. The approach I have alrea...
Involucel asked 27/1, 2015 at 17:57

21

Solved

Situation: I have a large object containing multiple sub and sub-sub objects, with properties containing multiple datatypes. For our purposes, this object looks something like this: var object = {...
Picro asked 28/3, 2013 at 19:40

8

Solved

I know I'm not supposed to mutate the input and should clone the object to mutate it. I was following the convention used on a redux starter project which used: ADD_ITEM: (state, action) => ({...
Anastomosis asked 3/1, 2016 at 23:7

17

Solved

How to remove first and last element in an array? For example: var fruits = ["Banana", "Orange", "Apple", "Mango"]; Expected output array: ["Orange", "Apple"]
Thistledown asked 10/1, 2011 at 6:6

7

I have a confusion in how NaN works. I have executed isNaN(undefined) it returned true. But if I will use Number.isNaN(undefined) it is returning false. So which one I should use? Also why there is...
Fremitus asked 16/10, 2015 at 7:24

9

I'm trying to find a way with javascript to highlight the text the user selects when they click some odd highlight button (as in <span style="background-color:yellow">highlighted text</spa...
Mishmash asked 20/11, 2008 at 10:6

23

Solved

Can someone help me with a javascript function that can highlight text on a web page. And the requirement is to - highlight only once, not like highlight all occurrences of the text as we do in cas...
Sandysandye asked 27/12, 2011 at 12:5

20

Solved

Sometimes I need to wait for a .forEach() method to finish, mostly on 'loader' functions. This is the way I do that: $q.when(array.forEach(function(item){ //iterate on something })).then(functi...
Picard asked 16/7, 2016 at 1:41

25

Solved

How can I create an array with 40 elements, with random values from 0 to 39 ? Like [4, 23, 7, 39, 19, 0, 9, 14, ...] I tried using solutions from here: http://freewebdesigntutorials.com/javaScr...
Taw asked 29/4, 2011 at 20:5

29

Solved

I have .env file at root folder file NODE_ENV=development NODE_HOST=localhost NODE_PORT=4000 NODE_HTTPS=false DB_HOST=localhost DB_USERNAME=user DB_PASSWORD=user And server.js file in the root/...
Parable asked 20/2, 2017 at 1:15

17

I use react-router-dom version 6 and when I use this.props.history.push('/UserDashboard') it does not work. I changed it to const history = createBrowserHistory(); history.push('/UserDashboard') b...
Seyler asked 18/8, 2020 at 15:33

11

I have a form that, when submitted, I need to do some additional processing before it should submit the form. I can prevent default form submission behavior, then do my additional processing (it's ...
Ledoux asked 17/1, 2013 at 8:47

8

Solved

I have a function that takes data from server: function getData(data){ console.log(data.someVar); } WebStorm says that someVar is an unresolved variable. How can I get rid of such warnings? I see...
Idelia asked 30/12, 2013 at 7:53

17

Solved

In a Node.js project I am attempting to get data back from S3. When I use getSignedURL, everything works: aws.getSignedUrl('getObject', params, function(err, url){ console.log(url); }); My...
Gomel asked 29/4, 2016 at 15:39

24

Solved

I have the next code, eslint throw: react/prop-types onClickOut; is missing in props validation react/prop-types children; is missing in props validation propTypes was defined but eslint does not...
Kuth asked 31/7, 2016 at 14:19

19

While running npx react-native init appName in MacBook air M1 chip TypeError: cli.init is not a function at run (/opt/homebrew/lib/node_modules/react-native-cli/index.js:302:7) at createProject (/o...
Atlantic asked 27/6, 2022 at 7:16

2

Solved

I have popup.html where popup.js is invoked when popup is loaded by clicking on browser action. There I'm programmatically injecting content scripts with chrome.tabs.executeScript(). I need to appe...
Cacodemon asked 4/3, 2015 at 15:17

32

Solved

Error TS1149: File name 'C:/Project/frontend/scripts/State.ts' differs from already included file name '../frontend/scripts/State.ts' only in casing. I've triple checked the casing in our refer...
Jayme asked 5/7, 2018 at 18:40

10

Solved

Let's say I have "scripts": { "pre-build": "echo \"Welcome\" && exit 1", "build_logic": "start cmd.exe @cmd /k \"yo esri-appbuilder-js:widget && exit 1\"", "post_build": "start...
Takara asked 26/8, 2016 at 18:22

8

Solved

I want to be able to execute the command script1 in a project directory that will run node script1.js. script1.js is a file in the same directory. The command needs to be specific to the project d...
Cologne asked 5/4, 2016 at 17:45

9

Solved

Why doesn't the following work for me? <script> document.getElementById('lbltipAddedComment').innerHTML = 'Your tip has been submitted!'; </script> <label id="lbltipAddedComment"&g...
Planarian asked 20/12, 2010 at 10:23

16

Solved

How do I display a hyperlink in a React Native app? e.g. <a href="https://google.com>Google</a>
Tonneson asked 29/5, 2015 at 22:52

3

as the title states I am creating a website using NextJS styled with TailwindCSS. However, there is a small and annoying issue with my code. Here is my code below for the MainContent of the page: &...
Crispen asked 26/1, 2023 at 0:32

21

Solved

I'm using React Router v6 and am creating private routes for my application. In file PrivateRoute.js, I've the code import React from 'react'; import {Route,Navigate} from "react-router-dom&qu...
Brunt asked 6/11, 2021 at 12:55

22

Solved

As the title of my post suggests, I would like to know how many digits var number has. For example: If number = 15; my function should return 2. Currently, it looks like this: function getlength(n...
Homogeneity asked 14/2, 2013 at 16:39

© 2022 - 2024 — McMap. All rights reserved.