
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
1K+ Views
To replace a value if null or undefined, you can use below syntax −var anyVariableName= null; var anyVariableName= yourVariableName|| anyValue;Examplevar value = null; console.log("The value ="+value) var actualValue = value || "This is the Correct Value"; console.log("The value="+actualValue);To run the above program, you need to use the following command −node ... Read More

AmitDiwan
311 Views
For this, use onkeypress. Let’s first create input text −Now, let’s see the demoForEnterKey() function and check whether enter key is pressed or not −function demoForEnterKey(eventName) { if (eventName.keyCode == 13) { var t = document.getElementById("textBox"); console.log(t.value); console.log("Enter key is ... Read More

AmitDiwan
3K+ Views
Let’s first create array of strings −let studentDetails = [ {studentName: "John Smith"}, {studentName: "john smith"}, {studentName: "Carol Taylor"} ];Now, match case insensitive substring, use the filter() and the concept of toLowerCase() in it. Following is the code −Examplelet studentDetails = [ {studentName: "John Smith"}, ... Read More

AmitDiwan
346 Views
To generate array of n equidistant points along a line segment of length x, use the below syntax −for (var anyVariableName= 0; yourVariableName< yourStartPointName; yourVariableName++) { var v = (yourVariableName+1)/ (yourStartPointName+1); var v2 = v*yourEndPointName;Examplefunction drawPoints(start, end) { const arrayOfPoints = [] for (var index = ... Read More

AmitDiwan
398 Views
You need to call the same function again and again to sum all integers from nested array. Following is the code −Examplefunction sumOfTotalArray(numberArray){ var total= 0; for (var index = 0; index < numberArray.length; index++) { if (numberArray[index] instanceof Array){ total=total+sumOfTotalArray(arr[index]); ... Read More

AmitDiwan
6K+ Views
You can use the keyCode 13 for ENTER key. Let’s first create the input −Now, let’s use the on() with keyCode to detect the ENTER key. Following is the complete code −Example Live Demo Document $("#txtInput").on('keyup', function (event) { ... Read More

AmitDiwan
2K+ Views
To create an empty array of given size, use the new operator −var numberArray = new Array(10);After that, let’s set some values in the array. Following is the code −Examplevar numberArray = new Array(10); console.log("The length="+numberArray.length) numberArray=[10, 20, 30, 40, 50, 60]; console.log("The array value="); for(var i=0;i node demo52.js The ... Read More

AmitDiwan
556 Views
Let’s first set a button − Call Above, we have set a function under “onclick” to call two other functions −function callTwoOtherFunctions(){ fun1(); fun2(); }In this way, work around the fun1() and fun2() as in the complete code below −Example Live Demo Document ... Read More

AmitDiwan
673 Views
To check for valid date format, match the date with −const dateFormat = /^\d{4}\-\d{2}\-\d{2}$/;Example Live Demo Document .check-valid-date { border: 1px solid red; } const dateFormat = /^\d{4}\-\d{2}\-\d{2}$/; document.getElementById("check-valid-date").addEventListener("change", checkingForValidDate); ... Read More

AmitDiwan
383 Views
To modify string, you can use toLowerCase() as well as toUpperCase(). Let’s say the following is our string −var sentence = "tHIS iS tHE JavaScript pROGRAM";To modify and display in proper case, the code is as follows −Examplevar sentence = "tHIS iS tHE JavaScript pROGRAM"; function modifyStringWithMultipleMethods(sentence) { return ... Read More