Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Articles on Trending Technologies
Technical articles with clear explanations and examples
How to create a custom object in JavaScript?
JavaScript offers multiple ways to create custom objects. Each method has its own syntax and use cases, making JavaScript flexible for object-oriented programming. Method 1: Using Object Constructor The new Object() constructor creates an empty object that you can populate with properties: var dept = new Object(); dept.employee = "Amit"; dept.department = "Technical"; dept.technology = "Java"; ...
Read MoreWhat is super() function in JavaScript?
The super() function in JavaScript is used to call the constructor of the parent class and access methods from the parent class within a child class. It's essential for proper inheritance in ES6 classes. Syntax super() // Call parent constructor super.method() // Call parent method Using super() in Constructor When extending a class, you must call super() before using this in the child constructor: ...
Read MoreHow to call a JavaScript function on submit form?
The onsubmit event occurs when you try to submit a form. You can put your form validation against this event type. The following example shows how to use onsubmit. Here we are calling a validate() function before submitting a form data to the webserver. If validate() function returns true, the form will be submitted, otherwise it will not submit the data. Basic Syntax Method 1: Using onsubmit Attribute The most common approach is to use the onsubmit attribute directly in the form ...
Read MoreHow to provide new line in JavaScript alert box?
To add a new line in JavaScript alert box, use the "" escape character: Syntax alert("First lineSecond line"); Basic Example function showAlert() { alert("This is line oneThis is line twoThis is line three"); } Click to Show Alert Multiple Line Breaks You ...
Read MoreHow to call a JavaScript function from an onmouseover event?
The onmouseover event triggers when you bring your mouse over any element. You can call JavaScript functions when this event occurs to create interactive web experiences. Syntax content Method 1: Using DOM Manipulation Modern approach using getElementById() and innerHTML instead of document.write(): function over() { document.getElementById("result").innerHTML = "Mouse Over"; } ...
Read MoreHow to show prompt dialog box using JavaScript?
JavaScript has several built-in methods to create dialog boxes that allow users to interact with them. The prompt() method in JavaScript is one of them. The prompt dialog box is very useful when you want to pop up a text box to get user input. In this article, we'll explore how to use the prompt() method with examples. What is a Prompt Dialog Box? The prompt() method in JavaScript is used to display a dialog box that prompts the user for input. The prompt dialog box is very useful when you want to pop up a text box ...
Read MoreHow do you get a timestamp in JavaScript?
In this tutorial, we will learn to get a timestamp in JavaScript. It never happens that software developers or application developers don't require to play with date and time. In many situations, they are required to play with date and timestamp. For example, to show the time on the user's dashboard, save the time of an operation in the database. Now, let's understand what the timestamp is? The timestamp is the total number of milliseconds from the 1st January 1970 from when UNIX epochs begin. Using the timestamp, we can extract the date, day, year, month, hours, minutes, second, ...
Read MoreHow to use JavaScript to show a confirm message?
In this tutorial, we will learn how to use JavaScript to show a confirm message. We use window.confirm() method of JavaScript to show a confirm message. A confirm message is enclosed in a confirm dialog box which is a modal window. Such a window takes focus upon being created and doesn't go out of focus until the user responds to it. Confirmation Dialog Box in JavaScript A confirm message is a yes/no message for the user that requires immediate attention. A confirmation dialog box usually gets triggered in response to some action requested by the user. This action ...
Read MoreHow to call a JavaScript function from an onClick event?
The onClick event is the most frequently used event type, which occurs when a user clicks the left button of the mouse. You can put your validation, warning etc., against this event type. Basic Syntax Click me Example: Simple onClick Function You can try to run the following code to call a JavaScript function from an onClick event: function display() { ...
Read MoreWhat is the lifetime of JavaScript variables?
The lifetime of a JavaScript variable refers to how long it exists in memory, from creation to destruction. Variable lifetime depends on scope and the execution context where it's declared. Local Variable Lifetime Local variables are created when a function is called and destroyed when the function completes execution. They exist only within their function scope. function checkScope() { var localVar = "I'm local"; // Created when function starts console.log(localVar); // localVar is destroyed when function ends } checkScope(); ...
Read More