Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
AmitDiwan has Published 10740 Articles
AmitDiwan
242 Views
You can use keyword async as well as await. Following is the code −Exampleasync function test(i) { while (i node demo73.js Call Demo1() Call Demo2() Call Demo1() Call Demo2() Call Demo1() Call Demo2() Call Demo1() Call Demo2() Call Demo1() Call Demo2() Call Demo1() Call Demo2() Call Demo1() Call ... Read More
AmitDiwan
1K+ Views
To get value of any attribute from XML data, use attr() in JavaScript. Following is the code −Example Live Demo Document var yourXMLDetails = '' +'' +'' +'' console.log("Game Details==="+$(yourXMLDetails).attr("details")); To run the above ... Read More
AmitDiwan
290 Views
Let’s say the following is our object −var customerDetails= [ { customerId:101, customerName:"John" }, { customerId:102, customerName:"David" }, { customerId:103, customerName:"Mike" }, { customerId:104, customerName:"Bob" } ]Use for loop with the following condition to display only odd CustomerID records −for(var index=0;index
AmitDiwan
2K+ Views
You can use the concept of createHTMLDocument(). Following is the code −Example Document const htmlDocument = document.implementation.createHTMLDocument(); const customURL = htmlDocument.createElement( 'base' ); customURL.href = "https://www.tutorialspoint.com/java/index.htm"; htmlDocument.head.append( customURL ); console.log("Base URL="+customURL.href); const modifiedURL = ... Read More
AmitDiwan
2K+ Views
To select all elements with “data-“ attribute, use document.querySelectorAll(“”). Following is the code −Example Live Demo Document var result=document.querySelectorAll('[data-sentence]'); for (var index in result){ if (result.hasOwnProperty(index)){ console.log(result[index].getAttribute('data-sentence')); ... Read More
AmitDiwan
1K+ Views
To match multiple occurrences in a string, use regular expressions. Following is the code −Examplefunction checkMultipleOccurrences(sentence) { var matchExpression = /(JavaScript?[^\s]+)|(typescript?[^\s]+)/g; return sentence.match(matchExpression); } var sentence="This is my first JavaScript Program which is the subset of typescript"; console.log(sentence); console.log(checkMultipleOccurrences(sentence));To run the above program, you need to use the ... Read More
AmitDiwan
384 Views
The includes() check whether array has a specific element, whereas splice() is used to add/remove items. Following is the code −ExampledeleteElementsFromArray = function(elements, ...values) { let elementRemoved = Array.from(values); for (var index = 0; index < elements.length; index++){ if (elementRemoved.includes(elements[index])){ elements.splice(index, ... Read More
AmitDiwan
578 Views
You can use a for loop and check whether the percentage is greater than 70 or not with if condition.Following are the records of each student −const studentDetails= [ { studentName:"John", percentage:78 }, { studentName:"Sam", ... Read More
AmitDiwan
424 Views
To get seconds since epoch, use the below syntax −var anyVariableName= new Date(); Math.round(yourDateVariableName.getTime() / 1000);At first, get the current date −var currentDate= new Date();Now, get seconds since epoch −Examplevar currentDate= new Date(); var epochSeconds = Math.round(currentDate.getTime() / 1000); console.log(epochSeconds);To run the above program, you need to use the following ... Read More
AmitDiwan
838 Views
As we know the value 0 is for day Sunday and 6 for Saturday. First of all, you need to get day with the help of getDay().Let’s set a date −var givenDate=new Date("2020-07-18");Now, we will get the day −var currentDay = givenDate.getDay();Following is the code to determine if date is ... Read More