- 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
![Swarali Sree](https://www.tutorialspoint.com/assets/profiles/13515/profile/60_84115-1512649510.jpg)
141 Views
Fat arrow function as the name suggests helps in decreasing line of code. The syntax => shows fat arrow. This also avoids you to write the keyword “function” repeatedly. Arrow functions are generally used for a non-method function. Let’s see how to use arrow functions used as methods:ExampleYou can try to run the following code to implement arrow functions used as methodsLive Demo 'use strict'; var ob1 = { val1: 75, val2: 100, x: () => document.write(this.val1, this), y: function() { document.write(""+this.val1, this); }, z: function() { document.write(""+this.val2, this); }, } ob1.x(); ob1.y(); ob1.z();
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
536 Views
Fat arrow function as the name suggests helps in decreasing line of code. The syntax => shows fat arrow. This also avoids you to write the keyword “function” repeatedly.Here’s the syntax:argument => expressionUse the following for more than one argument:(argument1 [, argument2]) => expressionLet’s compare a function with and without fat arrow:Function in JavaScriptvar rank = [7,8,9]; var display = rank.map(function(num) { return num * num; });Fat Arrow function in JavaScriptvar rank= [7,8,9]; var display = rank.map((num) => num*num); document.write(arr)Arrow function definitely reduces the code lines.
![Rahul Sharma](https://www.tutorialspoint.com/assets/profiles/14297/profile/60_102977-1513054044.jpg)
382 Views
The increment and decrement operators should be avoided since it can lead to unexpected results. Here are some of the conditions:In an assignment statement, it can lead to unfavorable results:ExampleLive Demo var a = 5; var b = ++a; var c = a++; var d = ++c; document.write(a); document.write("\r"+b); document.write("\r"+c); document.write("\r"+d); OutputWhitespace between the operator and variable can also lead to unexpected results:a = b = c = 1; ++a ; b -- ; c;
![Shubham Vora](https://www.tutorialspoint.com/assets/profiles/485898/profile/60_1456867-1657516792.jpeg)
2K+ Views
In this tutorial, we will see if we can declare JavaScript variables as a specific type or not. The JavaScript contains the three reserve keywords to declare the variables: ‘let, ’ ‘var’, and ‘const.’ When the user declares the variable using any keyword, it has a different scope. The variable declared with the const keyword always remains constant, and we can’t change its value after initializing it. The variables declared with the let keyword have block scope and can’t be accessed outside its scope. When we declare the variables with the var keyword, it can have the global scope or ... Read More
![Shubham Vora](https://www.tutorialspoint.com/assets/profiles/485898/profile/60_1456867-1657516792.jpeg)
375 Views
This tutorial teaches us to make an array empty in JavaScript. While programming with JavaScript, programmers need to make an array empty in many conditions. For example, coders are doing competitive programming with JavaScript. Suppose, to solve some problem, they need to create a new or an empty array while calling the function every time. Users can visualize this problem from the below example.function child ( ){ // create a new array or use a single array and make it empty every time function invokes } function parent ( ) { for ( int ... Read More
![Shubham Vora](https://www.tutorialspoint.com/assets/profiles/485898/profile/60_1456867-1657516792.jpeg)
3K+ Views
In this tutorial, we will learn to check the existence of the variable, which means whether the variable is declared and initialized or not in JavaScript. In many scenarios, JavaScript programmers need to check the presence of the variable. Otherwise, it throws a reference error if we use it without declaring or defining it.For example, Programmers have defined the variable and it is uninitialized. Programmers want to change the variables' value through the data they will get from API calls. Suppose that the value of the uninitialized variable is not updated due to some error during the API call. If ... Read More
![Rahul Sharma](https://www.tutorialspoint.com/assets/profiles/14297/profile/60_102977-1513054044.jpg)
159 Views
To check a variable is ‘undefined’, you need to check using the following. If the result is “false”, it means the variable is not defined. Here, the variable results in “True” −ExampleLive Demo var points = 100; if(points){ document.write("True"); }else{ document.write("False"); }
![Johar Ali](https://www.tutorialspoint.com/assets/profiles/14293/profile/60_101691-1513053093.jpg)
280 Views
functionDisplayOne is a function expression, however, functionDisplayTwo is a function declaration. It is defined as soon as its surrounding function is executed.Both the ways are used to declare functions in JavaScript and functionDisplayOne is an anonymous function.Here’s the function expression −functionDisplayOne(); var functionDisplayOne = function() { console.log("Hello!"); };The following is the function declaration −functionDisplayTwo(); function functionDisplayTwo() { console.log("Hello!"); }