Found 6710 Articles for Javascript

What are common HTML Events supported by JavaScript?

Jennifer Nicholas
Updated on 23-Jun-2020 06:45:25

177 Views

The following are some of the common HTML events supported by JavaScript −AttributeValueDescriptiononclickscriptTriggers on a mouse clickoncontextmenuscriptTriggers when a context menu is triggeredondblclickscriptTriggers on a mouse double-clickondragscriptTriggers when an element is draggedondragendscriptTriggers at the end of a drag operationondragenterscriptTriggers when an element has been dragged to a valid drop targetondragleavescriptTriggers when an element is being dragged over a valid drop targetondragoverscriptTriggers at the start of a drag operationondragstartscriptTriggers at the start of a drag operationondropscriptTriggers when dragged element is being droppedondurationchangescriptTriggers when the length of the media is changed

How to pass an object as a parameter in JavaScript function?

Shubham Vora
Updated on 13-Sep-2023 15:33:27

34K+ Views

In this tutorial, we will learn how to pass an object as a parameter in a JavaScript function. One of JavaScript's data types is represented by the Object type. It is used to store keyed collections as well as more complex entities. The Object() function Object()or the object initializer / literal syntax can be used to create objects. Almost all JavaScript objects are instances of Object; a typical object inherits properties (including methods) from Object.prototype, though these properties may be shadowed (a.k.a. overridden). Following are the methods used to pass an object as a parameter in a JavaScript function. Using the ... Read More

How to catch any JavaScript exception in Clojurescript?

Sravani Alamanda
Updated on 08-Dec-2022 10:23:09

221 Views

In our code, usually, we will get an issue with errors. Errors will disturb the normal flow of our application. So, it is required to handle error exceptions in our code to implement any application in any programming language. Now, we will see how to handle exceptions in Clojurescript. Before that, first we learn what Clojurescript is. What is ClojureScript? At the fundamental level, Closurescript is an accent of the closure programming language that is used to compile to JavaScript. Actually, closure originally compiled only to Java virtual machine bytecode, later in 2011 Closurescript came as an option to ... Read More

How to define custom JavaScript exceptions?

V Jyothi
Updated on 23-Jun-2020 06:33:30

174 Views

To learn how to define and implement custom JavaScript exceptions, you can try to run the following code −Example                                         Click the following to see the result:                          

How to catch all JavaScript unhandled exceptions?

Rishi Rathor
Updated on 23-Jun-2020 06:34:11

841 Views

To catch all JavaScript unhandled exceptions, use window.error. The onerror event handler provides three pieces of information to identify the exact nature of the error −Error message − The same message that the browser would display for the given errorURL − The file in which the error occurredLine number− The line number in the given URL that caused the errorExampleYou can try to run the following code to catch unhandled exceptions −                                         Click the following to see the result:                          

How to use Custom Exceptions in JavaScript?

Nancy Den
Updated on 23-Jun-2020 06:35:16

209 Views

Use throw statement in JavaScript, to catch custom exceptions. You can try to run the following to work with custom exceptions −Example                                             Click the following to see the result:                          

How can we use a JavaScript function as an object?

Shubham Vora
Updated on 14-Jul-2022 13:22:47

2K+ Views

This tutorial will teach us to use the JavaScript functions as an object. However, functions, objects, and arrays are the mutable data types in JavaScript, and all mutable data types are the objects.The JavaScript object is one type of entity that contains the key-value pairs. It contains unique keys; every key has some values that can be of any type. We can use the object key to access the values of the objects.We can create a function so that it behaves like an object. Below, we have given a detailed explanation of converting the function to an object.Use JavaScript function ... Read More

How can we assign a function to a variable in JavaScript?

Shubham Vora
Updated on 14-Jul-2022 13:18:22

26K+ Views

In this tutorial, we will learn to assign a function to a variable in JavaScript. The function is the code block that we can reuse quickly, often just by making a function call. There are two ways to declare a function in JavaScript, one is a named function, and another is an anonymous function.Most JavaScript programmers are familiar with the name function, and users can follow the below syntax to declare the named function.function function_name() { //function body }In the above syntax, users can see that, we can create a function definition with the function keyword and following by function ... Read More

How to invoke a JavaScript Function as a method?

Shubham Vora
Updated on 14-Sep-2022 13:53:52

1K+ Views

In this tutorial, we will learn how to invoke a JavaScript Function as a method. In JavaScript, the code inside a function will execute when the function is invoked. We can invoke a function in a variety of ways. One of them is using the method. The method is a property of an object that has a function value. We can define functions as object methods. This function will have a function name, a parameter (optional), and a return type (optional). It will have a "this" keyword which refers to an object. Users can follow the syntax below to declare ... Read More

How to invoke a JavaScript Function as a function?

Shubham Vora
Updated on 14-Sep-2022 13:50:14

228 Views

In this tutorial, we will learn how to invoke a JavaScript Function as a function. Functions are a set of reusable codes that perform a specific task and may return a value. In JavaScript, functions are defined by the keyword function. A function has different parts, like a function name, parameter list, function body, and return statement. A function may not have any parameters and may also not have any return statement. In JavaScript, we also have functions with no function names, called anonymous functions. Users can follow the syntax below to declare a function. // function declaration function function_name(parameter1, ... Read More

Advertisements