- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- 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 8895 Articles for Front End Technology
7K+ Views
Use Math.abs() inside a JavaScript function to get the difference between two numbers in JavaScript.ExampleYou can try to run the following code to get the difference of numbersLive Demo var num1, num2; num1 = 50; num2 = 35; var difference = function (num1, num2){ return Math.abs(num1 - num2); } document.write("Difference = "+difference(num1,num2));
145 Views
In this tutorial, we will discuss what the operator || does in a var statement in JavaScript. The logical OR operator or logical disjunction on the operands returns true if any of the operand values are true, false, ’’, null, undefined, 0, and NaN are the false values. All other values are true. The logical OR operands must be either boolean, integer, or a pointer kind. The logical OR returns the latest operand if there is no true value. The logical OR executes from left to right. Users can follow the syntax below for using the logical OR operator. Syntax ... Read More
334 Views
The purpose of a self-executing is that those variables declared in the self-executing function are only available inside the self-executing function.Variables declared in the self-executing function are, by default, only available to code within the self-executing function.It is an immediately invoked function expression (IIFE). It is a function, which executes on creation.SyntaxHere is the syntax −(function() { // code })();As you can see above, the following pair of parentheses converts the code inside the parentheses into an expression:function(){...}In addition, the next pair, i.e. the second pair of parentheses continues the operation. It calls the function, which resulted from the ... Read More
10K+ Views
In this tutorial, we will see how to extract the hostname portion of a URL in JavaScript. What is a URL? An alternative term for a web address is a URL. For example, tutorialpoints.com is a word-based URL. An IP address can also be used as a URL (ex. 192.168.2.24). Since names are simpler to recall than numbers, most users submit the name’s address when searching on the internet A URL is a method by which web browsers ask web servers for specific pages. The syntax/format of a URL is given below. Syntax scheme://prefix.domain:port/path/filename Parameters scheme − specifies ... Read More
2K+ Views
A JavaScript function can have an optional return statement i.e. it’s optional to return a value. This statement should be the last statement in a function.For example, you can pass two numbers in a function and then you can expect the function to return their multiplication to your calling program.ExampleTry the following example. It defines a function that takes two parameters and concatenates them before returning the resultant in the calling program.Live Demo function concatenate(first, last){ var full; full = first ... Read More
6K+ Views
JavaScript is used everywhere, from creating the back end using environments like Node.js to creating the front end using React.js, Vue.js, etc. In JavaScript, the uses of a function are very high, it is used for performing a group operation, it is used as a callback, as a constructor, and in many more places. With the high use of functions in JavaScript, the code becomes full of functions everywhere and looks messy and hard to debug. At a point, it is difficult to find which functions trigger which event and which callbacks are used for what, so it is ... Read More
2K+ Views
In this tutorial, let us discuss the methods to use unlimited arguments in a JavaScript function. The number of arguments in a JavaScript function is a bit tricky. If we specify three arguments should follow the correct order of the arguments. Let us discover the solution to this problem by introducing the methods to pass unlimited in a function, we can not pass more than three. Moreover, we arguments to a JavaScript function. Using ES5 Arguments Object Instead of converting the arguments object to an array, we can process the arguments object with the total number of arguments. Follow the ... Read More
10K+ Views
This tutorial will teach us how to declare optional function parameters in JavaScript. While declaring the function, we pass some variables to the function definition to use it inside the function block, called function parameters. The function parameters can also be optional, which gives us the independence to pass function arguments when we call the function. Here, Arguments are the values we pass while calling the function, and parameters are the variables we pass in the function definition.Optional ParametersThe optional parameter word means that you don’t need to pass that parameter every time you call the function, giving you the ... Read More
392 Views
In this article, we will learn about the Multiplication assignment operator (*=) in JavaScript. In general, we use a = a * b this expression to update the value of a variable with the value returned after multiplying its original value with some other value, which is easy to understand, but it time taking to write again and again if we are using updating values of more variables like this. So, to overcome this problem, JavaScript introduces us to the multiplication assignment operator (*=) as it is the short form for using the above expression. The multiplication Assignment operator (*=) ... Read More