Common HTML Events Supported by JavaScript

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

183 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

What are JavaScript Identifiers

Smita Kapse
Updated on 23-Jun-2020 06:44:09

5K+ Views

JavaScript Identifiers are names given to variables, functions, etc. It is the same as identifiers in other programming languages like C, C++, Java, etc. Let’s see identifiers for variable names.The following are legal variable names −val val1 resultWhile naming your variables in JavaScript, keep the following rules in mind.You should not use any of the JavaScript reserved keywords as a variable name. These keywords are mentioned in the next section. For example, break or boolean variable names are not valid.JavaScript variable names should not start with a numeral (0-9). They must begin with a letter or an underscore character. For ... Read More

Launch JavaScript Debugger in Google Chrome

Abhinaya
Updated on 23-Jun-2020 06:40:20

299 Views

To launch JavaScript debugger in Google Chrome, try any of the following ways,Press Ctrl + Shift + JGo to Settings and click More Tools. After that, click Developer Tools.For more, refer the official website of  Chrome Dev Tool,

Use Custom Exceptions in JavaScript

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

218 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:                          

Catch All JavaScript Unhandled Exceptions

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

853 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:                          

Define Custom JavaScript Exceptions

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

180 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:                          

What are Callback Functions in JavaScript

Nancy Den
Updated on 23-Jun-2020 06:20:32

482 Views

When a function is passed to another function, it is called a callback function. It goes over this function than to call a passed function.ExampleYou can try to run the following code to learn how to work with callback functions −                    var callback = function(myCallback) {             setTimeout(function() {                myCallback();             }, 5000);          };                    document.write("First is displayed");          document.write("Second is displayed");                    callback(function() {              document.write("This is Callback function");          });          document.write("Last is displayed");          

Extract Numbers from a String Using Python

Jayashree
Updated on 23-Jun-2020 06:13:54

733 Views

To extract each digit from a string −>>> str1='a34e 345 bcd 5he 78 xyz' >>> for s in str1: if s.isdigit():print (s) 3 4 3 4 5 5 7 8To extract only integers from a string in which words are separated by space character −>>> str1='h3110 23 cat 444.4 rabbit 11 2 dog' >>> for s in str1.split(): if s.isdigit(): print ((s)) 23 11 2

Return an Object from a JavaScript Function

Abhinaya
Updated on 23-Jun-2020 06:07:20

6K+ Views

To return an object from a JavaScript function, use the return statement, with this keyword.ExampleYou can try to run the following code to return an object from a JavaScipt function − Live Demo                    var employee = {             empname: "David",             department : "Finance",             id : 002,             details : function() {                return this.empname + " with Department " + this.department;             }          };          document.write(employee.details());           Output

Difference Between Custom and Built-in Functions in JavaScript

Anvi Jain
Updated on 23-Jun-2020 06:00:13

689 Views

The custom functions in JavaScript are user-defined functions. JavaScript allows us to write our own functions. The following is the syntax −Syntax     Bult-in functions are functions already provided by JavaScript library, for example, the following are string functions −S. NoMethod & Description1charAt()Returns the character at the specified index.2charCodeAt()Returns a number indicating the Unicode value of the character at the given index.3concat()Combines the text of two strings and returns a new string.4indexOf()Returns the index within the calling String object of the first occurrence of the specified value, or -1 if not found.ExampleThe following is an example of a built-in ... Read More

Advertisements