JavaScript math ceil() method

The JavaScript math ceil() method is used to get the smallest integer value, either greater than or equal to a number. Syntax: Math.ceil(n) Parameters n: It represents the number. Returns The smallest integer value which will be greater than or equal to the specified number. Example: <!DOCTYPE html> <html> <body> <script> document.writeln(Math.abs(-345)); </script> </body> </html>

JavaScript math atan() method

The JavaScript math atan() method is used to get the arc-tangent of the given number in radians. It returns the value between -Math.PI/2 to Math.PI/2. Syntax: Math.atan(n) Parameters n: It represents the number whose arc-tangent has to be get. Returns Arc-tangent value of a number Example: <!DOCTYPE html> <html> <body> <script> document.writeln(Math.atan(0)); </script> </body> </html>

Add method to JavaScript object

We can add a method to a JavaScript object. First, define a method and then assign that method as a property to an object. Example: <html> <body> <script> function stuClassName(className){ this.className=className; } function Student(name,rollNo){ this.name=name; this.rollNo=rollNo; this.stuClassName= stuClassName; } var student=new Student(“Jai”, “MCA/07/06”); student.stuClassName(“MCA Final”); document.write(“Name: ” +student.name + “</br>”); document.write(“RollNo: ” + student.rollNo + … Read more

Operator precedence in JavaScript

In every language, evaluation of an expression is done based on a predefined order of precedence which helps the language engine to determine which part of the expression will be evaluated first, which will second, and so on. Operator precedence in JavaScript Operator Operation Order of Precedence Order of Evaluation ++ Increment 1 R -> L … Read more

JavaScript IP address validation

IP address validation in JavaScript is used to ensure that the number entered in the specified IP address field should be a valid IP address. Regular Expression: /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?) \.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/ Example: <!DOCTYPE html> <html lang=”en”> <head> <script> function ipAddressCheck(ipAddress) { var regEx = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?) \.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/; if(ipAddress.value.match(regEx)) { return true; } else { alert(“Please enter a valid … Read more