2,525,024 questions
34
votes
16
answers
40k
views
How to test if something is a class?
I am trying to test if the argument passed into my function is a class name so that I may compare it to other classes using instanceof.
For example:
function foo(class1, class2) {
// Test to see if ...
1
vote
1
answer
28
views
"Uncaught TypeError: Cannot read properties of undefined" when accessing nested object in JavaScript React component
Problem:
I am trying to display a user's address from a nested user object in my React component. When the component first loads, I get an Uncaught TypeError: Cannot read properties of undefined (...
73
votes
12
answers
40k
views
How to check if a function is a constructor
I noticed not all the Javascript functions are constructors.
var obj = Function.prototype;
console.log(typeof obj === 'function'); //true
obj(); //OK
new obj(); //TypeError: obj is not a constructor
...
12253
votes
51
answers
13.6m
views
How can I remove a specific item from an array in JavaScript?
How do I remove a specific value from an array? Something like:
array.remove(value);
Constraints: I have to use core JavaScript. Frameworks are not allowed.
3
votes
3
answers
13k
views
Press and hold button does not fire onClick
I'm having a problem with the button in my HTML5 application.
When I press the button a Video player runs and plays the video that is stored locally. My issue now is that when I hold the button and ...
2
votes
1
answer
12k
views
datatables bootstrap modal not working
I am trying to get a click to open editable content of my dyniamically generated rows in modals, using datatables plugin.
I see an error:
Uncaught TypeError: Cannot read property 'display' of ...
0
votes
1
answer
3k
views
TS Error for Luxon DateTime: Cannot use namespace 'DateTime' as a type
I've imported both luxon and types/luxon and whenever I try and set the type to luxons 'DateTime' object I get the error DateTime: Cannot use namespace 'DateTime' as a type.
Here is some example code ...
-3
votes
1
answer
79
views
How do I debug a type error in web development? [closed]
I am learning web development and sometimes I get type errors when running my project. I understand that a type error usually means the program is trying to use a value in the wrong way, but I’m not ...
-3
votes
1
answer
37
views
Converting a PHP object array to a JavaScript object array
First, I retrieve the data from the database using PHP oop called it $details. $details contain several object array totally about 7. Each object array has a PHP object fields are service_idno, ...
Best practices
1
vote
4
replies
64
views
How can one create mini quiz app project with pure vanilla JavaScript. i'm a learner, after the structuring the html / css i couldn't continue
How can i create a mini quiz app with pure vanilla JavaScript which takes questions and presents options which include the correct answer and output the scores with a next button which switches the ...
1
vote
1
answer
196
views
How do web platforms like Twitter, Instagram or Facebook allow other web sites to embed their content?
I have a specific type of content that has JavaScript, HTML and CSS components. I want other web sites to be able to embed this specific content on their websites and mobile-websites. How should I go ...
1
vote
4
answers
365
views
How to get background color of a site?
Let me explain. I am not looking for a particular attribute of a particular DOM element. I started thinking that if I checked the background-color of the body element, I would find the background ...
-1
votes
2
answers
428
views
How I can insert a URL to all array elements individually in JS
var countries = ['Afghanistan',"Albania","Algeria"];
var Links=["http://www.google.com","http://www.yahoo.com","http://www.bing.com"];
/*initiate ...
2
votes
2
answers
688
views
How to place link-tags on a map
I would like to create a interactive map feature via HTML, CSS and JavaScript. Therefore I need to place Link-Tags(or similar) on a map. The following image illustrates what I am trying to achieve:
...
1
vote
2
answers
9k
views
How do I add a thumbnail to my web site so that when someone shares a link on Twitter or Facebook it shows the image and the link?
How do I add a thumbnail to my web site so when a user shares the link to Twitter or Facebook it shows the link with the image in HTML and JavaScript?
So what I exactly want is that when the user ...