
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

175 Views
The JavaScript undefined property specifies if a variable has been declared or assigned a value yet.Following is the code for the JavaScript undefined property −Example Live Demo Document body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } .sample { font-size: 18px; font-weight: 500; color: red; } JavaScript undefined property CLICK HERE CLICK the above button to know if variable age has been defined or not let sampleEle = document.querySelector(".sample"); let ... Read More

1K+ Views
To trigger a button on the Enter key in JavaScript, you can do it by using JavaScript keyboard events. Keyboard interactions are very essential in web development, and developers must use them effectively for a better user experience. This is especially helpful for forms, search boxes, and places where you enter information. In this article, we will explore different ways to detect and handle the ENTER key press event in JavaScript. To trigger a button on enter key in JavaScript, you can do it the following ways: Using keyup() event: ... Read More

194 Views
The JavaScript this keyword refernces the object to which it belongs. It can refer to the global object if alone or inside a function. It refers to the owner object if inside a method and refers to the HTML element that received the event in an event listener.Following is the code for the JavaScript this Identifier −Example Live Demo Document body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } .sample { font-size: 18px; font-weight: 500; color: red; } ... Read More

153 Views
The JavaScript source property returns the regexp text against which a given pattern is to matched.Following is the code for the source property −Example Live Demo Document body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } .sample, .result { font-size: 18px; font-weight: 500; color: red; } .result { color: rebeccapurple; } JavaScript source property The king bought a ring CLICK HERE Click on the above button to get the regex source text let resultEle = document.querySelector(".result"); let pattern = /ing/gi; document.querySelector(".Btn").addEventListener("click", () => { resultEle.innerHTML = "Regexp text = " + pattern.source; }); OutputOn clicking the ‘CLICK HERE’ button −

360 Views
In this article, we will learn to set the object keys by variable in JavaScript. Objects are dynamic collections of properties. We can use variables to add or change properties rather than using static keys. This is specifically helpful when handling dynamic data, like user input. Dynamic Key Assignment In JavaScript, object properties can be retrieved and assigned using bracket notation ([ ]). It enables the use of a string or variable as the key, so dynamic assignment of object properties is possible. Syntax object[variable] = value; Here, the object is the target object, the variable is the variable containing ... Read More

403 Views
Regular expressions are a string of characters describing a search pattern. This search pattern is then used to specify what we are searching in a text.Following is the code for regular expressions in JavaScript −Example Live Demo Document body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } .sample, .result{ font-size: 18px; font-weight: 500; color:red; } JavaScript Regular Expressions The king bought the ring and went to the palace. CLICK HERE Click on the above ... Read More

618 Views
In JavaScript, redirecting a user from one URL to another is a straightforward task. There are multiple ways to achieve this, but we’ll focus on two of the most common and effective methods: window.location.href and window.location.replace(). Both are widely used for different purposes, and understanding when to use each one can help improve user navigation on your site. Approaches to Redirect a URL in JavaScript Following are the different approaches to redirect a URL: Using window.location.href Using window.location.replace() Redirect a URL Using window.location.href Property The window.location.href property is one of ... Read More

216 Views
The Math.random() function is used to generate a random floating-point number between 0 and 1.Following is the code for Math.random() function −Example Live Demo Document body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } .sample { font-size: 18px; font-weight: 500; color: red; } JavaScript Random CLICK HERE Click on the above button to generate a random number between 1 to 10 let sampleEle = document.querySelector('.sample'); document.querySelector('.Btn').addEventListener('click',()=>{ let num = Math.floor((Math.random()*10))+1; sampleEle.innerHTML = 'Number generated = ' + num; }) OutputOn clicking the “CLICK HERE” button −

1K+ Views
Promises in JavaScript allow us to do asynchronous operations where the value is not known in advanced when the promise was being created. A promise can have three states pending, fulfilled and rejected.Following is the code for promises in JavaScript −Example Live Demo Document body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } .sample { font-size: 18px; font-weight: 500; color: red; } JavaScript Promises CLICK HERE Click on the above button to display username ... Read More

202 Views
Properties in JavaScript are the values associated with an object. Following is the code implementing object properties in JavaScript −Example Live Demo Document body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } .sample { font-size: 18px; font-weight: 500; color: red; } JavaScript Object Properties CLICK HERE Click on the above button to display name and age property from testObj object let sampleEle = document.querySelector(".sample"); document.querySelector(".Btn").addEventListener("click", () => { let testObj = { name: "Rohan",age: 23,}; sampleEle.innerHTML += "testObj.name = " + testObj.name + ""; sampleEle.innerHTML += "testObj.age = " + testObj.age + ""; }); OutputOn clicking the ‘CLICK HERE’ button −