I am using match like this: text.match(v = /(d+.d+.d+.d+)/g). But When es-lint run it shows an error that v is not defined I tried this: text.match(‘v = /(d+.d+.d+.d+)/g’) But now match is not working. Answer It looks like you’re trying to do this: but inline. You generally should not be ass…
Category: Questions
How can I pass a variable to be used as the condition in a filter?
I am trying to filter an array of full names by a specific first name. I have created the filterFirstName function which accepts arguments for the name and the criteria to compare it to. I then use that function in my filter. I looked up the syntax for filter callback(element[, index[, array]]. The element is…
Run PHP after JS validation
I am doing email validation for admin registration using JavaScript and save the data to database using PHP. Supposedly, the registration is done only if the email is valid. But when the email evaluates to invalid, the PHP code still run. How do I do it so that when the email is invalid, the PHP won’t r…
How can I fetch a specific array from the JSON data and display it?
Firstly apologies as I am fairly new to fetching from an API and I am trying to learn. I need to fetch “name” , “age” and “phone” from “id” 1 from “is” and display it when click on button. This is my javascript-fetch-api.js file: I’m not sure h…
Creating a field in an a object if it doesn’t exist, incrementing it if it does if it does, for multiple objects?
I have a collection “users” There’s a notifications field that has an object. Every field of this object corresponds to a chat channel ID and they value is the amount of notifications in the channel (unread messages). If user “u101” and “u102” are both in the the same…
Unknown column ‘narozeni’ in ‘field list’ [closed]
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers. This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers. Closed 3 m…
Swift/Foundation NotificationCenter equivalent in JavaScript
I’m looking for a Swift/Foundation NotificationCenter equivalent in vanilla JS. Here’s a short explanation on what NotificationCenter is: With NotificationCenter, you’re able to post a notification and other objects can subscribe to that notification. When the notification gets sent, a funct…
Get the count of only disabled type=”number” input boxes
How can I expand this to count all input boxes in a form that is type=”number” but is currently disabled? I can count all the input boxes (which included checkboxes) but I want to only count the specific disabled boxes only. Answer I would use querySelectorAll (which deals with CSS selectors natur…
Need of a call(), apply() and bind() method
I have read lot of theory regarding call(), apply() and bind(). I am not able to understand if we can call method directly why we need call() , apply() or bind()? Can somebody explain in laymen terms and little in terms of JavaScript? Answer That’s the flexibility offered by Javascript, an object and it…
How to escape a sup tag in xpath selector
I want to extract the text content from the below HTML tag, but the <sup> tag is preventing me from getting the desired text. The text I want to extract is simply (4:6, 6:7). how can I extract this text at the same time escaping the <sup> tag. I tried this “//p/text()”, but I am only g…