Articles on Trending Technologies

Technical articles with clear explanations and examples

How to create a custom object in JavaScript?

vanithasree
vanithasree
Updated on 15-Mar-2026 591 Views

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 More

What is super() function in JavaScript?

radhakrishna
radhakrishna
Updated on 15-Mar-2026 334 Views

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 More

How to call a JavaScript function on submit form?

mkotla
mkotla
Updated on 15-Mar-2026 16K+ Views

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 More

How to provide new line in JavaScript alert box?

Rishi Rathor
Rishi Rathor
Updated on 15-Mar-2026 833 Views

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 More

How to call a JavaScript function from an onmouseover event?

varma
varma
Updated on 15-Mar-2026 2K+ Views

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 More

How to show prompt dialog box using JavaScript?

Disha Verma
Disha Verma
Updated on 15-Mar-2026 982 Views

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 More

How do you get a timestamp in JavaScript?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 5K+ Views

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 More

How to use JavaScript to show a confirm message?

Abhishek Kumar
Abhishek Kumar
Updated on 15-Mar-2026 7K+ Views

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 More

How to call a JavaScript function from an onClick event?

varun
varun
Updated on 15-Mar-2026 2K+ Views

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 More

What is the lifetime of JavaScript variables?

Govinda Sai
Govinda Sai
Updated on 15-Mar-2026 1K+ Views

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
Showing 19031–19040 of 61,297 articles
Advertisements