Tutorialspoint

How do we use throw statement in JavaScript?

With JavaScript, how to work with throw statement in JavaScript? I also want to learn its implementation while working with JavaScript.
Daniol Thomas
Answered on 16th Feb, 2018

With JavaScript, use throw statement to raise your built-in exceptions or your customized exceptions. Later these exceptions can be captured and you can take an appropriate action.You can try to run the following code to implement throw statement in JavaScript:<html>    <head>       <script>         ... Read More

What is onerror() Method in JavaScript?

I am learning how to handle JavaScript errors these days. What is the role of onerror() method in JavaScript? How can I implement it easily?
Abhinaya
Answered on 16th Feb, 2018

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.You can try to run the following code to implement onerror() method in JavaScript:<html>    <head>       <script>   ... Read More

How do we use try...catch...finally statement in JavaScript?

With JavaScript, how to work with try…catch…finally statements? What is the usage of such statements and how can I implement all these statements in a single program?
Govinda Sai
Answered on 16th Feb, 2018

The latest versions of JavaScript added exception-handling capabilities. 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.Here is the try...catch...finally block syntax:<script>    <!--       try {         ... Read More

What are runtime errors in JavaScript?

What do you mean by runtime errors in JavaScript? I want to learn when runtime errors occur and what can be the causes?
Rishi Rathor
Answered on 16th Feb, 2018

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 ... Read More

Regular expression to match numbers only in JavaScript?

I know how to work with regular expressions in JavaScript. However, struggling to create one to match only numbers in JavaScript. Which regular expression should I use to match numbers only fro.....
Ramu Prasad
Answered on 16th Feb, 2018

You can try to run the following code to implement regular expressions for matching only numbers:<html>    <head>       <title>JavaScript Regular Expressions</title>    </head>    <body>       <script>          var myStr = "5200% Demo";          var reg = /\d/g; ... Read More

What are syntax errors in JavaScript?

What do you mean by syntax errors in JavaScript? I want to learn when syntax errors occur and what can be the causes?
Prabhas
Answered on 16th Feb, 2018

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.<script>    <!--       window.print(;    //--> </script>When a syntax error occurs in ... Read More

How to get the current time in millisecond using JavaScript?

With JavaScript, I want to get the current time in millisecond. Which method is to be used in JavaScript to achieve this?
Sravani S
Answered on 16th Feb, 2018

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. You can try to run the following code to get the ... Read More

How to get the exponent power of a number in JavaScript?

I want to get the exponent power of a number. Which method is to be used in JavaScript to achieve this?
V Jyothi
Answered on 16th Feb, 2018

To get the exponent power of a number, use the Math.pow (base, exponent ) method. This method returns the base to the exponent power, that is, base exponent. The following are the parameters used in Math.pow() method:base − The base number. exponents − The exponent to which to raise base.You can try to run the ... Read More

How to get the value of a number rounded to the nearest integer in JavaScript?

Which method is to be used in JavaScript to display the value of a number rounded to the nearest integer? The following are the numbers: ,
vanithasree
Answered on 16th Feb, 2018

Use the Math.round() method to get the value of a number rounded to the nearest integer. You can try to run the following code to return the value of a number rounded to the nearest integer in JavaScript:<html>    <head>       <title>JavaScript Math round() Method</title>    </head>   ... Read More

How to calculate the area and perimeter of a circle in JavaScript?

With JavaScript, how to work with the area and perimeter of a circle? I want to calculate it using JavaScript functions.
radhakrishna
Answered on 16th Feb, 2018

To calculate the area and perimeter of a circle, you can try to run the following code:<html>    <head>       <title>JavaScript Example</title>    </head>    <body>       <script>          function Calculate(r) {             this.r = r;     ... Read More

How to create RegExp object in JavaScript?

With JavaScript, how to work with RegExp object? I want to learn its usage and implementation in JavaScript.
Priya Pallavi
Answered on 16th Feb, 2018

A regular expression is an object that describes a pattern of characters. The JavaScript RegExp class represents regular expressions, and both String and RegExp define methods that use regular expressions to perform powerful pattern-matching and search-and-replace functions on the text.A regular expression could be defined with the RegExp () constructor, ... Read More

What are regular expressions in JavaScript?

What are regular expressions and how to work with it in JavaScript? I am learning JavaScript these days after getting knowledge about HTML and its tags.
mkotla
Answered on 16th Feb, 2018

A regular expression is an object that describes a pattern of characters. The JavaScript RegExp class represents regular expressions, and both String and RegExp define methods that use regular expressions to perform powerful pattern-matching and search-and-replace functions on the text.A regular expression could be defined with the RegExp () constructor, ... Read More

How to convert a negative number to a positive one in JavaScript?

Which JavaScript method is to be used in JavaScript to convert a negative number to positive? What would happen when we will try to convert the following: ,
Nikitha N
Answered on 16th Feb, 2018

To convert a negative number to a positive one in JavaScript, use the abs() method in JavaScript. The method returns the absolute value of a number.You can try to run the following code to convert a negative number to positive:<html>    <head>       <title>JavaScript Math abs() Method</title>   ... Read More

How to do basic Maths with JavaScript Operators?

With JavaScript, how can I perform basic mathematical operations such as add, subtract, division, etc. Which operators should I use in JavaScript to achieve this?
Krantik Chavan
Answered on 16th Feb, 2018

To do basic Maths such as +, -, * in JavaScript, use the Operators. JavaScript includes operators for basic mathematics such as Addition, Subtraction, Multiplication, etc.You can try to run the following code to learn how to work with basic Maths i.e. Mathematical Operators in JavaScript:<html>    <body>     ... Read More

What are C++ Character Constants?

What are C++ Character Constants? Please explain this with an example?
Samual Sam
Answered on 16th Feb, 2018

Character constants are one or more members of the “source character set, ” the character set in which a program is written, surrounded by single quotation marks ('). They are used to represent characters in the “execution character set, ” the character set on the machine where the program executes. ... Read More

Advertisements
Loading...
Unanswered Questions View All