
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 10744 Articles

AmitDiwan
253 Views
For this, you can use the concept of focus(). Following is the code −Example Live Demo Document Submit const submitButton = document.getElementById('submitBtn'); submitButton.addEventListener('click', () => { console.log('Submitting information to the server.....'); }) ... Read More

AmitDiwan
1K+ Views
To filter null from an array and display only non-null values instead, use filter(). Following is the code −Examplevar names=[null, "John", null, "David", "", "Mike", null, undefined, "Bob", "Adam", null, null]; console.log("Before filter null="); console.log(names); var filterNull=[]; filterNullValues=names.filter(obj=>obj); console.log("After filtering the null values="); console.log(filterNullValues);To run the above program, you need ... Read More

AmitDiwan
254 Views
Let’s say the following is our object −const subjectDetails ={ 102:"Java", 105:"JavaScript", 104:"MongoDB", 101:"MySQL" };Use sort() method to retrieve object’s entry in order −const orderSubjects = Object.fromEntries(Object.keys(subjectDetails).sort().map((k) => { return [k, subjectDetails[k]]; }));Exampleconst subjectDetails ={ 102:"Java", 105:"JavaScript", 104:"MongoDB", 101:"MySQL" }; const ... Read More

AmitDiwan
1K+ Views
To print JSON nested object in JavaScript, use for loop along with JSON.parse(). Following is the code −Examplevar details = [ { "studentId": 101, "studentName": "John", "countryName": "US", "subjectDetails": "{\"0\":\"JavaScript\", \"1\":\"David\"}" }, { ... Read More

AmitDiwan
6K+ Views
To get HTML form values, use the value property. Let’s say the following is our input type −We need to display the above value “My name is John Smith” on console.Example Live Demo Document var originalvalue = document.getElementById("getValues").value; ... Read More

AmitDiwan
121 Views
For this, use the concept of reduce(). Following is the code −Exampleconst subjectDetails = [ { subjectId: '101', subjectName: 'JavaScript' }, { subjectId: '102', subjectName: 'Java' }, { subjectId: '103', ... Read More

AmitDiwan
3K+ Views
To create, use add() method, whereas to delete created and appended element, you can use remove(). Following is the code −Example Live Demo Document Add A New Name AddName ... Read More

AmitDiwan
3K+ Views
Let’s get the current date first −var currentDate = new Date(); console.log("The current date is as follows="+currentDate);Now, let us remove seconds/ milliseconds by setting them to 0 using setSeconds() −currentDate.setSeconds(0, 0);Convert to ISO String using toISOString() −currentDate.toISOString()Let us now see the complete code with output −Examplevar currentDate = new Date(); ... Read More

AmitDiwan
519 Views
To toggle hide class only on selected div, you need to set event on click button. Let’s say you need to hide a specific div on the click of + sign.To get font + or - icon, you need to link font-awesome −Following is the code to toggle hide class ... Read More

AmitDiwan
592 Views
To parse float with two decimal places, use the concept of toFixed(2). Following is the code −Examplevar price = 178932.89; var tax = 7.9; var totalPrice = price*tax; console.log("The actual value="+totalPrice); var gettingTwoPlacedValues = parseFloat(totalPrice).toFixed(2); console.log("After getting two placed values="+gettingTwoPlacedValues);To run the above program, you need to use the following ... Read More