
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
104 Views
Let’s say our original string is the following with repeated letters −var values = "DDAAVIDMMMILLERRRRR";We want to remove the repeated letters and precede letters with numbers. For this, use replace() along with regular expression.ExampleFollowing is the code −var values = "DDAAVIDMMMILLERRRRR"; var precedingNumbersInString = values.replace(/(.)\1+/g, obj => obj.length + obj[0]); ... Read More

AmitDiwan
170 Views
For this, use Object.keys() and set one key on each iteration as null using a for loop..ExampleFollowing is the code −var objectValues = { "name1": "John", "name2": "David", "address1": "US", "address2": "UK" } for (var tempKey of Object.keys(objectValues)) { var inEachIterationSetOneFieldValueWithNull = { ... Read More

AmitDiwan
593 Views
Use localStorage.setItem(“anyKeyName”, yourValue) to set the value in local storage and if you want to fetch value then you can use localStorage.getItem(“yourKeyName”)ExampleFollowing is the code − Live Demo Document var textBoxNameHTML = document.getElementById('txtName'); ... Read More

AmitDiwan
526 Views
Let’s say we have the following array −var studentDetails = [ [89, "John"], [78, "John"], [94, "John"], [47, "John"], [33, "John"] ];And we need to sort the array on the basis of the first item i.e. 89, 78, 94, etc. For this, use sort().ExampleFollowing is ... Read More

AmitDiwan
802 Views
Let’s say the following is our array −var details = [ { studentName: "John", studentMarks: [78, 98] }, { studentName: "David", studentMarks: [87, 87] }, { studentName: "Bob", ... Read More

AmitDiwan
291 Views
For this, use the addEventListener() with mousedown event.ExampleFollowing is the code − Document document.addEventListener("mousedown", function () { console.log("Mouse down event is happening"); }); To run the above program, save ... Read More

AmitDiwan
1K+ Views
At first, set a new Date in JavaScript −var dateValue = new Date("2021-01-12 10:10:20");Use new Date() along with setHours() and getHours() to add time.ExampleFollowing is the code −var dateValue = new Date("2021-01-12 10:10:20"); dateValue.setHours(dateValue.getHours() + 2); console.log("The date value is=" + dateValue.toString()); console.log("Only Hours value after incrementing=" + dateValue.getHours());To run ... Read More

AmitDiwan
342 Views
For this, use forEach() along with [] to an associative array.ExampleFollowing is the code −var result = {}; var names = ['John', 'David', 'Mike', 'Sam', 'Bob', 'Adam']; names.forEach((nameObject, counter) => { var generatedValues = { [nameObject]: counter }; Object.assign(result, generatedValues) }) console.log(result);To run the above program, you need ... Read More

AmitDiwan
2K+ Views
Let’s say the following is our button −Press MeOn filling the below input field, the color of the above button should change −ExampleFollowing is the code − Live Demo Document UserName: ... Read More

AmitDiwan
132 Views
If the const is used in a program, and if you try to reassign the value to const variable then an error will arise.Let’s say the following is our const variable −const result = (first, second) => first * second;Now, we will try to reassign a value to the const ... Read More