Shubham Vora

Shubham Vora

793 Articles Published

Articles by Shubham Vora

Page 46 of 80

Explain the working of timers in JavaScript

Shubham Vora
Shubham Vora
Updated on 05-Jan-2023 720 Views

In JavaScript, timers are a very noteworthy feature. As like the normal watch timer, we can start the timer at a time and execute the function or code in JavaScript after a particular time. In simple terms, we can use the timer to execute the code after some delay. For example, when you visit some website, it shows the signup box after 3 to 4 minutes of your visit, and that we can achieve using JavaScript. We can set the delay timer to show the signup popup box. Another good example of the timer in real life is ads ...

Read More

Explain the differences in the usage of foo between function foo() {} and var foo = function() {}

Shubham Vora
Shubham Vora
Updated on 05-Jan-2023 1K+ Views

In JavaScript, we have different ways to define the functions. The function foo() {} and var foo = function() { } is two different ways to define the function. Both ways have their benefits and different use cases; however, both give the same result when executing the function. So, this tutorial will teach us the difference between both ways to define a function. Explanation of the function foo() { }: function declaration The function foo() { } is the normal way to declare the function in JavaScript, which every beginner and developer uses. Also, we can call it a named ...

Read More

Explain the benefits of spread syntax & how it is different from rest syntax in ES6?

Shubham Vora
Shubham Vora
Updated on 05-Jan-2023 358 Views

In the ES6 version of JavaScript, spread syntax is introduced as a very powerful feature. We can use the spread syntax to expand the array or objects into the variable of the same data type. For example, before the spread syntax was introduced in the ES6, developers were using the for loop to copy all elements of one array to another array. Can you copy all elements of one array to another by writing one linear code using the spread syntax rather than writing the 5 to 7 lines of code using the for loop? Yes, you heard right! ...

Read More

Explain the concept of null and its uses in TypeScript

Shubham Vora
Shubham Vora
Updated on 05-Jan-2023 4K+ Views

In TypeScript, ‘null’ refers to the data type or value. The null is a keyword in TypeScript, which we can use to represent the absent or empty value. So, we can use ‘null’ to define the variable's data-type or initialize the variable. In this tutorial, we will learn the different use cases of the null value and data type in TypeScript. Syntax Users can follow the syntax below to use the null keyword as a data type or value. let null_var: null = null; In the above syntax, ‘null’ refers to the data type of the null_var named ...

Read More

Explain the Scope and Scope Chain in JavaScript

Shubham Vora
Shubham Vora
Updated on 05-Jan-2023 2K+ Views

In JavaScript, the scope defines how and in which part of our code we can access the variables and functions. In simple terms, the scope helps us improve our code's security and readability. So, we can access the variables and functions only inside its scope but not outside. We will discuss multiple types of scopes in this tutorial. Global Scope in JavaScript The variables and functions defined globally mean outside all blocks and functions with global scope. We can access all variables and functions with the global scope anywhere inside our code. Syntax Users can follow the syntax below ...

Read More

How to search for an array element in TypeScript?

Shubham Vora
Shubham Vora
Updated on 03-Jan-2023 25K+ Views

In TypeScript, while working with the array, we often require to search for a particular element. To search for an element, either we can use the naive approach using the for loop or some built-in method such as the find() or indexOf() method. Also, we will learn to find the particular object in the array based on the object property. Using the for-of Loop to Search a Particular Element in The Array The naive approach to searching for an element is using linear search. In linear search, we need to iterate through the array using the for loop and check ...

Read More

How to specify optional properties in TypeScript?

Shubham Vora
Shubham Vora
Updated on 03-Jan-2023 1K+ Views

We will learn to specify the option properties in TypeScript. The true meaning of the optional property is that properties can be undefined or null, and we can initialize them whenever required. In real-time development, the importance of optional properties is very much. For example, we are fetching the data from the API and performing some operations on the data. If you try to use the data without getting it due to the database server being down or if there is any other problem, it will raise an error. In such case, we can make the data property optional and ...

Read More

How to find the natural logarithm of a number in TypeScript?

Shubham Vora
Shubham Vora
Updated on 03-Jan-2023 717 Views

The natural logarithm is the logarithm of any numeric value to the base e. Here e is Euler's constant, and the value of Euler’s constant is approximately 2.718. In TypeScript, we can use the built-in library methods to find the natural logarithm of any numeric value greater than or equal to zero. Using the Math.log() Method Math is a library of TypeScript which contains all the methods to perform mathematical operations. Inside the Math object, all methods are static. So, we can directly access all methods by taking Math (object name) as a reference. The math method also contains the ...

Read More

How to create an array of objects in TypeScript?

Shubham Vora
Shubham Vora
Updated on 03-Jan-2023 16K+ Views

In TypeScript, the array contains the data or different values and can also contain an object. The object contains the properties and methods in TypeScript. We can access the object properties and invoke the object method by taking the object as a reference. In this tutorial, we will learn to create an array of multiple objects in TypeScript. We will also learn to perform some operations, such as sorting on the array of objects. Syntax Here, we have given the syntax to follow to create the array of objects. let obj_array: Array = [{object properties}] In the above syntax, ...

Read More

Explain Enum in TypeScript

Shubham Vora
Shubham Vora
Updated on 03-Jan-2023 606 Views

Before getting into “enum, ” it is essential to know about the popular keyword “const” in typescript. When we declare a variable "const", we cannot change the value assigned to it. So, enums are nothing but a collection of these const data types. We can create enums with the help of the "enum" keyword. Enum is an abbreviation for Enumerations, and each constant variable declared under the enum is called a member of that enum. In this article, we will learn about enums in typescript, their features, and the major types of enums. Features of enum in TypeScript Enums ...

Read More
Showing 451–460 of 793 articles
« Prev 1 44 45 46 47 48 80 Next »
Advertisements