Latest Questions in Javascript

Browse latst posts in Javascript Category

4
Votes
Published 16 Apr, 2022
Javascript - TypeError: undefined is not an object (evaluating 'store.getState')

I'm following the Let’s Build: Cryptocurrency Native Mobile App With React Native + Redux tutorial. When I create my store in App.js, the app works fine import { createStore, applyMiddleware, compos...

1
Votes
Published 16 Apr, 2022
Javascript - Typescript error - 'boolean' is not assignable to type 'number'

Can anybody help me. I am trying to sort strings from array var someArray= ["3a445a_V1", "3", "2a33s454_V1", "1", "3_V2", "2s4a34s3_V2", "234343"]; const [record] = someArray.map(r => parseFloat...

6
Votes
Published 16 Apr, 2022
Javascript - Error: The type cast expression is expected to be wrapped with parenthesis when using get function

Without the curly braces (they aren't parentheses), your code would be invalid JavaScript because you have a property initializer (params: ) outside an object literal, where the parser is expecting an...

45
Votes
Published 16 Apr, 2022
Javascript - How to make side panel in chrome extension?

I have been learning to create a chrome extension. I have tried hello world example and it was working fine. Now I have been trying to add custom code and make some changes in the hello world code acc...

21
Votes
Published 16 Apr, 2022
Javascript - How to send JSON object as JSON String with Postman?

I want to send a JSON request but problem is I need to send my userPropertiesAsJsonString field as JSON string. How can I send userPropertiesAsJsonString as JSON string? { "User" : { "u...

5
Votes
Published 16 Apr, 2022
Javascript - Lodash: is it possible to use map with async functions?

Consider this code const response = await fetch('<my url>'); const responseJson = await response.json(); responseJson = _.sortBy(responseJson, "number"); responseJson[0] = await addEnabledPr...

3
Votes
Published 24 Apr, 2022
Javascript - How to pass a queryset from django to javascript function?

I want to pass a queryset from a view to a javascript function throught the template: my view.py: def myview(request): lista=Mymodel.objects.filter(tipo=mytipo) context_dict['lista']=lis...

1
Votes
Published 24 Apr, 2022
Javascript - Passing FormData/File Object from content script to background script in chrome extension with Manifest V3

I'm building a chrome extension where I get a file as input from the user and pass it to my background.js (service worker in case of manifest v3) to save it to my backend. Since making cross-origin re...

39
Votes
Published 16 Apr, 2022
Javascript - How to get the actual rendered font when it's not defined in CSS?

I suggest this function: function css( element, property ) { return window.getComputedStyle( element, null ).getPropertyValue( property ); } Usage: css( object, 'font-size' ) // returns '16px' fo...

31
Votes
Published 10 Jun, 2022
Javascript - How to run one request from another using Pre-request Script in Postman

I'm trying to send an authenticated request with one click in postman. So, I have request named "Oauth" and I'm using Tests to store the token in a local variable. var jsonData = JSON.parse(response...

342
Votes
Published 16 Apr, 2022
Javascript - What is JavaScript's highest integer value that a number can go to without losing precision?

Is this defined by the language? Is there a defined maximum? Is it different in different browsers?

2
Votes
Published 16 Apr, 2022
Javascript - How to get the value of all p and h tags in a html page excluding all other tags

I am trying to load a HTML page into my app. I want to show only the content of the HTML page. please help me with a javascript function where I can loop through all the p tags and get the content of...

61
Votes
Published 16 Apr, 2022
Javascript - Split string once in javascript?

How can I split a string only once, i.e. make 1|Ceci n'est pas une pipe: | Oui parse to: ["1", "Ceci n'est pas une pipe: | Oui"]? The limit in split doesn't seem to help...

27
Votes
Published 15 Apr, 2022
Javascript - Click on a button to copy a text from an input to clipboard

The use of navigator.clipboard requires a secure origin. So if your dev environment is being served over HTTP, then the clipboard method won't be available. According to MDN Clipboard docs: "This feat...

2
Votes
Published 24 Apr, 2022
Javascript - Importing Javascript library (jsencrypt) into Angular 2 app

I have looked through all the tutorials revolving around this issue, and havn't been able to find a solution. Some background first. I have a Angular 2 app and I need to use this JS library for encryp...

21
Votes
Published 10 Jun, 2022
Javascript - How do I restrict past dates in html5 input type Date

I am trying to restrict past dates in input type="date".I can able to restrict future dates,But I don't have idea about restricting past dates. $(function(){ var dtToday = new Date();...

67
Votes
Published 09 Jun, 2022
Javascript - React Apexcharts Line Chart line not visible

I am using apexcharts library with React for implementing a line chart. It renders but the line to display the curve is not visible. This may be a large set of series data. When I reduce the set of d...

313
Votes
Published 16 Apr, 2022
Javascript - Create an array with same element repeated multiple times

In Python, where [2] is a list, the following code gives this output: [2] * 5 # Outputs: [2,2,2,2,2] Does there exist an easy way to do this with an array in JavaScript? I wrote the following func...

38
Votes
Published 08 Jun, 2022
Javascript - Nodemailer doesn't work, what's wrong?

I have a trouble with Nodemailer. It works on localhost and responds with an error message. What is wrong here? React.js code example: import React from 'react' import styles from './index.css' expo...

22
Votes
Published 23 Apr, 2022
Javascript - Select2 - use JSON as local data

I can get this to work... var options = [{id: 1, text: 'Adair, Charles'}] $('#names').select2({ data: options, }) But i cant work out how to get from here... alert(JSON.stringify(request.nam...