
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 6710 Articles for Javascript

346 Views
To catch exceptions in JavaScript, use try…catch…finally. JavaScript implements the try...catch...finally construct as well as the throw operator to handle exceptions.You can catch programmer-generated and runtime exceptions, but you cannot catch JavaScript syntax errors.ExampleYou can try to run the following code to learn how to catch exceptions in JavaScript − Live Demo Click the following to see the result:

19K+ Views
In this article, we will learn how to check the null values in JavaScript. The null value indicates the intentional absence of any object value. It is a JavaScript primitive value that is false when used in Boolean operations. This distinguishes null from the related primitive value undefined, which is an unintended absence of any object value. This is because a variable that has been declared but not given a value is undefined rather than null.You may visualize a variable as a box by using a real-world analogy. The box can hold things like a teapot, just like a variable ... Read More

2K+ Views
The onerror event handler was the first feature to facilitate error handling in JavaScript. The error event is fired on the window object whenever an exception occurs on the page.ExampleYou can try to run the following code to implement onerror() method in JavaScript − Click the following to see the result:

663 Views
In this tutorial, we will learn to use the throw statement in JavaScript. The “throw” is the reserved keyword in JavaScript, and Programmers can use the throw keyword to create the user-defined exception.Every programmer is not perfect, so they can’t write the JavaScript code without making a single error. It also happens that programmers are taking the input from the user, and an exception occurs if the user enters the invalid input. Some built-in exceptions include arithmetic exceptions, Index out-of-bound exceptions, etc. In some cases, programmers want to create their exception and can do it using the throw statement inside ... Read More

272 Views
There are three types of errors in programming: (a) Syntax Errors, (b) Runtime Errors, and (c) Logical Errors. Runtime errors, also called exceptions, occur during execution (after compilation/interpretation). For example, the following line causes a runtime error because here the syntax is correct, but at runtime, it is trying to call a method that does not exist. Exceptions also affect the thread in which they occur, allowing other JavaScript threads to continue normal execution.

299 Views
Syntax errors also called parsing errors, occur at compile time in traditional programming languages and at interpret time in JavaScript. For example, the following line causes a syntax error because it is missing a closing parenthesis. When a syntax error occurs in JavaScript, only the code contained within the same thread as the syntax error is affected and the rest of the code in other threads gets executed assuming nothing in them depends on the code containing the error.

5K+ Views
In this tutorial, we will learn regular expressions to match numbers only in JavaScript. Data is a core element in every webpage. We have to validate it as per the requirements. We often deal with the data and require correct input from the user. For example, the user can not put the letters inside the field to accept the phone number, or the input length should be ten numbers. To validate the data in JavaScript, regular expression is used. We often need to filter the necessary data and extract the matched data. Here, we are going to match all the ... Read More

2K+ Views
To get the current time in a millisecond, use the date getMilliseconds() method. JavaScript date getMilliseconds() method returns the milliseconds in the specified date according to local time. The value returned by getMilliseconds() is a number between 0 and 999.Example You can try to run the following code to get the current time in milliseconds − JavaScript getMilliseconds() Method var dt = new Date( ); document.write("getMilliseconds() : " + dt.getMilliseconds() );

13K+ Views
In this tutorial, we will learn to convert JavaScript date objects to a string. In JavaScript, we can invoke some methods on the string only. So, we need to convert the date to the string to use the date with such methods. Here, we have three different approaches to converting the date object to a string. Using the toString() Method In this approach, we will use the toString() method of JavaScript to convert the date object to a string. The toString() method is useful to convert the variable of any data type such as number, objects, or array to string. ... Read More

1K+ Views
In this tutorial, we will learn how to get the value of a number rounded to the nearest integer in JavaScript. The nearest integer of a number can be found in different ways in JavaScript. In this tutorial, we will see the two most popular ways of doing it− Using Math.round() method Without using the Math.round() method Rounding a number means taking the nearest integer value from that number. It is useful for mathematical calculations when you need an approximate value to simplify your calculation. For example: If you have a number like 0.9999999, then taking this number ... Read More