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
1K+ Views
For this, use Object.assign(). Following is the code −Exampleconst details = {john:{'studentName':'John'}, david:{'studentName':'David'}, mike:{'studen tName':'Mike'}, bob:{'studentName':'Bob'}, carol:{'studentName':'Carol'}}, join_values = ['David', 'Carol'], output = Object.assign( {}, ...Object .keys(details) .map(key => ({[key]: { ... Read More
AmitDiwan
16K+ Views
We will be creating two buttons, one for Increment and another Decrement −On clicking Increment (+), user will be able to increment the number in input type numberOn clicking Decrement (-), user will be able to decrement the number in input type numberExample Live Demo Document ... Read More
AmitDiwan
439 Views
Here, we have set “Aabout_us” and “Hhome_page” with incorrectly spellings as anchor text.You can use substring(1) along with innerHTML to remove the first character and display them correctly as “about_us” and “home_page” respectively.Example Live Demo Document Aabout_us ... Read More
AmitDiwan
377 Views
Let’s say the following are our arrays −var firstArray=[100, 200, 400]; var secondArray=[400, 100, 200];You can sort both the arrays using the sort() method and use for loop to compare each value as in the below code −Examplevar firstArray=[100, 200, 400]; var secondArray=[400, 100, 200]; function areBothArraysEqual(firstArray, secondArray) { ... Read More
AmitDiwan
550 Views
To access nested JSON property based on another property’s value, the code is as follows −Examplevar actualJSONData = JSON.parse(studentDetails()), studentMarks = getMarksUsingSubjectName(actualJSONData, "JavaScript"); console.log("The student marks="+studentMarks); function getMarksUsingSubjectName(actualJSONData, givenSubjectName){ for(var tempObj of actualJSONData){ if(tempObj.subjectName = givenSubjectName){ return tempObj.marks; } ... Read More
AmitDiwan
559 Views
To replace value from a specific position, use splice() in JavaScript. Following is the code −Examplevar changePosition = 2 var listOfNames = ['John', 'David', 'Mike', 'Sam', 'Carol'] console.log("Before replacing="); console.log(listOfNames); var name = 'Adam' var result = listOfNames.splice(changePosition, 1, name) console.log("After replacing="); console.log(listOfNames)To run the above program, you need to ... Read More
AmitDiwan
273 Views
Let’s say the following is our array −var numbers=[10, 101, 76, 56, 5, 210, 3, 100];To find the smallest number, the code is as follows −Examplefunction findMinimumElementUsingRecursive(numbers) { if (numbers.length==1){ return numbers[0]; } else if(numbers[0]>numbers[1]) { return findMinimumElementUsingRecursive(numbers.slice(1)); } else ... Read More
AmitDiwan
9K+ Views
To split a URL, use the split() method. Use toString() before that. Let us see an exampleExamplevar newURL="http://www.example.com/index.html/homePage/aboutus/"; console.log(newURL); var splitURL=newURL.toString().split("/"); console.log(splitURL);Above, we have set forward slash in the split() function, since we need to split the URL after every such slash.To run the above program, you need to use ... Read More
AmitDiwan
3K+ Views
The plus(+) sign before the variables defines that the variable you are going to use is a number variable.In the below code, there is brief description about plus sign. Following is the code −Examplevar firstValue="1000"; console.log("The data type of firstValue ="+typeof firstValues); var secondValue=1000; console.log("The data type of secondValue ="+typeof ... Read More
AmitDiwan
280 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