
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
165 Views
Let’s say the following are our arrays −var firstNamesArray=["John", "David", "Bob", "Sam", "Carol"]; var secondNamesArray=["Mike", "Carol", "Adam", "David"];The easiest way to perform array intersection is by using filter() along with includes(). Following is the code −Examplevar firstNamesArray=["John", "David", "Bob", "Sam", "Carol"]; var secondNamesArray=["Mike", "Carol", "Adam", "David"]; var intersectionOfArray=[]; intersectionOfArray=firstNamesArray.filter(v => ... Read More

AmitDiwan
919 Views
For this, use hasOwnProperty(). Following is the code −Examplevar markDetails1 ={ 'marks1': 78, 'marks2': 65 }; var markDetails2 ={ 'marks2': 89, 'marks3': 90 } function updateJavaScriptObject(details1, details2) { const outputObject = {}; Object.keys(details1) .forEach(obj => outputObject[obj] = (details2.hasOwnProperty(obj) ? details2[obj] : details1[obj])); ... Read More

AmitDiwan
195 Views
For this, you can use match() along with regular expression. Following is the code −Examplevar originalString="JJJJOHHHHNNNSSSMMMIIITTTTHHH"; var regularExpression=/(.)\1*/g; console.log("The original string="+originalString); var splitting=originalString.match(regularExpression); console.log("After splitting the original string="); console.log(splitting);To run the above program, you need to use the following command −node fileName.js.Here, my file name is demo139.js.OutputThis will produce the ... Read More

AmitDiwan
544 Views
Let’s say following is our array −var numbers=[10, 50, 80, 60, 89];To find the second largest element, the code is as follows −Examplevar numbers=[10, 50, 80, 60, 89]; var firstLargerNumber = Number.MIN_SAFE_INTEGER; var secondlargerNumber = firstLargerNumber; for(var tempNumber of numbers){ if(tempNumber > firstLargerNumber){ secondlargerNumber = firstLargerNumber; ... Read More

AmitDiwan
11K+ Views
Let’s say the following is our button −SubmitOn the basis of button id, on form submission, generate an alert −$("#submitForm").click(function() { alert("The Form has been Submitted."); });Example Live Demo Document CollegeId= CollegeName= Submit $("#submitForm").click(function() { alert("The ... Read More

AmitDiwan
384 Views
To get the yesterday date, first of all get the current date and subtract 1 from the current and use the function setDate(). The syntax is as follows −yourCurrentDateVariableName.setDate(yourCurrentDateVariableName.getDate() - 1);At first, get the current date −var currentDate = new Date();Now, get yesterday’s date with the following code −Examplevar currentDate ... Read More

AmitDiwan
420 Views
At first, set the characters and numbers −var storedCharacters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';To generate randomly, use Math.random(). Following is the code −Examplefunction generateRandom3Characters(size) { var generatedOutput= ''; var storedCharacters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; var totalCharacterSize = storedCharacters.length; for ( var index = 0; index < size; index++ ) { ... Read More

AmitDiwan
202 Views
Following is our object −const customerDetails=[ {customerFirstName: "David"}, {customerLastName: "Miller"}, {customerCountryName: "US"}, {customerAge: "29"}, {isMarried: false}, {customerCollegeName: null} ];Let’s assign values to a computed property using slice() along with map().Exampleconst customerDetails=[ {customerFirstName: "David"}, {customerLastName: "Miller"}, {customerCountryName: "US"}, {customerAge: "29"}, ... Read More

AmitDiwan
432 Views
Let’s say the following is our table − John David Mike Use the following with text() to get last item −$('table tr:last td')Example Live Demo Document John David Mike ... Read More

AmitDiwan
218 Views
Use return statement to assign function to variables. Following is the code −Example Live Demo Document .demo { background: skyblue; height: 20px; width: 75%; margin: 10px; padding: ... Read More