- 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 10711 Articles for Web Development
![Shubham Vora](https://www.tutorialspoint.com/assets/profiles/485898/profile/60_1456867-1657516792.jpeg)
1K+ Views
In this tutorial, we will learn to load a JavaScript function using the name of a variable. Functions are the block of statements that takes an input and displays the result to the user after an execution. We can use these blocks of codes repeatedly by only declaring the function, and these functions can help a programmer in many ways as it also reduces efforts. JavaScript also supports the use of functions like other programming languages. Functions in JavaScript can be either built-in or user-defined. There are different ways to declare a function and call it. Generally, a simple Function ... Read More
![Rishi Raj](https://www.tutorialspoint.com/assets/profiles/13777/profile/60_73169-1512647303.jpg)
1K+ Views
To hide a div when the user clicks outside of it, try to run the following codeExampleLive Demo window.onload = function(){ var hideMe = document.getElementById('hideMe'); document.onclick = function(e){ if(e.target.id !== 'hideMe'){ hideMe.style.display = 'none'; } }; }; Click outside this div and hide it.
![Vikyath Ram](https://www.tutorialspoint.com/assets/profiles/13780/profile/60_74413-1512648006.jpg)
243 Views
decodeURIComponentTo decode a URL component in JavaScript, use the decodeURLComponent() method.ExampleYou can try to run the following code to decode a URL component − Check function display() { var uri = "http://example.com/welcome msg.jsp?name=åmit&sub=programming"; // first encode var encode = encodeURIComponent(uri); var decode = decodeURIComponent(encode); var result = "Encode= " + ... Read More
![Kumar Varma](https://www.tutorialspoint.com/assets/profiles/13883/profile/60_73481-1512711460.jpg)
134 Views
In JavaScript, use any of the single or double quotes for a string. However, you should be consistent in whatever you select. Single and double quotes are the same in JavaScript −"Let us say: \"Life's good!\"" 'Let us say: "Life\'s good!"' “Let us say: \"Life\'s good!\"" 'Let us say: \"Life\'s good!\"'Let’s see an example, which is supported by ES6 −`Will you be "my" friend. I really liked it when I was a kid,.`;
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
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));
![Shubham Vora](https://www.tutorialspoint.com/assets/profiles/485898/profile/60_1456867-1657516792.jpeg)
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
![Fendadis John](https://www.tutorialspoint.com/assets/profiles/13534/profile/60_64028-1512539837.jpg)
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
![Shubham Vora](https://www.tutorialspoint.com/assets/profiles/485898/profile/60_1456867-1657516792.jpeg)
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
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
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
![Saurabh Jaiswal](https://www.tutorialspoint.com/assets/profiles/500262/profile/60_1406912-1660202490.jpg)
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