
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
Found 9150 Articles for Object Oriented Programming

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: Press Me function changeTheColorOfButtonDemo() { if (document.getElementById("changeColorDemo").value !== "") { document.getElementById("buttonDemo").style.background = "green"; } else { document.getElementById("buttonDemo").style.background = "skyblue"; } } To run ... Read More

131 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 variable and an erro can be seen in the output.ExampleFollowing is the code −const result = (first, second) => first * second; result = first => first =first*10; console.log(result(10, 20)); To run the above program, you need to use the following command −node fileName.js.Here, my file name is demo284.js.OutputThis will produce ... Read More

4K+ Views
Let’s say we have the following sample video tag on a web page You cannot play video here...... To hide a video on a web page, use yourVariableName.style.display=’none’.ExampleFollowing is the code − Document .hideVideo { display: block; z-index: 999; margin-top: 10px; margin-left: 10px; } You cannot play video here...... var hideVideo = document.getElementsByClassName("hideVideo")[0]; hideVideo.style.display = ... Read More

904 Views
Let’s say the following is our unsorted array with negative and positive numbers −var arr = [10, -22, 54, 3, 4, 45, 6];ExampleFollowing is the code to implement Bubble Sort −function bubbleSort(numberArray, size) { for (var lastIndex = size - 1; lastIndex > 0; lastIndex--) { for (var i = 0; i < lastIndex; i++) { if (numberArray[i] > numberArray[i + 1]) { var temp = numberArray[i]; numberArray[i] = numberArray[i + 1]; numberArray[i + ... Read More

350 Views
Let’s say the following is our array object −var arrayObject = [ "John", "David", "Mike" ]You can use length property to set the length to 0 and clear memoryThe syntax is as follows to clear memory −yourArrayObjectName.length=0; // To clear memory yourArrayObjectName.length=4; // To allocate memoryOutputThis will produce the following output on console −var arrayObject = [ "John", "David", "Mike" ] arrayObject.length = 0; console.log(arrayObject); arrayObject.length = 5; for (var i = 0; i < arrayObject.length; i++) ... Read More

1K+ Views
You can use event listeners for clicks.ExampleFollowing is the code − Live Demo Document First Division Second Division document.addEventListener('click', callEventFuncion) function callEventFuncion(event) { var div = document.querySelectorAll('.divDemo'); var titleResult = document.querySelectorAll('.my-title'); var result = Array.apply(0, div).find((v) => v.contains(event.target)); if (result) { console.log(" Incrementing Division Selection"); } else { ... Read More

300 Views
For this, use join(). It will concatenate the string value length-1.ExampleFollowing is the code −var count = 5; var values = new Array(count + 1).join('John'); console.log(values); var count1 = 5; var values1 = new Array(count1).join('John'); console.log(values1);To run the above program, you need to use the following command −node fileName.js. Here, my file name is demo274.js.OutputThis will produce the following output on console −PS C:\Users\Amit\javascript-code> node demo274.js JohnJohnJohnJohnJohn JohnJohnJohnJohn

1K+ Views
With Spread Operator, allow the expression to expand to multiple arguments, elements, variables, etc.You can use JSON.stringify() to convert the JavaScript object to string. Here, we have our object as the result of using spread operator on details1 and details2.ExampleFollowing is the code −var details1 = { name: 'John', age: 21 }; var details2 = { countryName: 'US', subjectName:'JavaScript' }; var result= { ...details1, ...details2}; console.log(JSON.stringify(result));To run the above program, you need to use the following command −node fileName.js. Here, my file name is demo267.js.OutputThis will produce the following output on console −PS C:\Users\Amit\javascript-code> node demo267.js {"name":"John", "age":21, "countryName":"US", "subjectName":"JavaScript"}Read More

203 Views
To validate a specific URL, use regular expression.ExampleThe code is as follows −function validateSoundURL(myURL) { var regularExpression = /^https?:\/\/(tutorialspoint\.com)\/(.*)$/; return myURL.match(regularExpression) && myURL.match(regularExpression)[2] } console.log(validateSoundURL("https://tutorialspoint.com/index")); console.log(validateSoundURL("https://tutorialspoint.com/java"));To run the above program, you need to use the following command −node fileName.js.Here, my file name is demo259.js.OutputThis will produce the following output on console −PS C:\Users\Amit\javascript-code> node demo259.js index java

237 Views
Yes, the not not operator is the reverse process of not operator. If any value is true then single ! (not) will return false and !! will return opposite value (true).The not operator −var flag=true; console.log(!flag);The not not operator −var flag=true; console.log(!!flag);ExampleFollowing is the code −var flag=true; console.log("The result of single !=") console.log(!flag); console.log("The result of single !!=") console.log(!!flag)To run the above program, you need to use the following command −node fileName.js. Here, my file name is demo247.jsOutputThis will produce the following output on console −PS C:\Users\Amit\javascript-code> node demo247.js The result of single != false The result of single !!= ... Read More