Found 26504 Articles for Server Side Programming

Golang program to find the largest element in a slice

Akhil Sharma
Updated on 17-Jan-2023 11:57:09

1K+ Views

In this tutorial, we will inculcate how to find the largest element in a slice using some examples. A slice is a sequence of elements just like an array. An array is a fixed sequence of elements whereas slice is a dynamic array which means its value is not fixed and can be changed. Slices are more efficient and faster than arrays moreover they are passed by reference instead by value. Let’s go through the example to understand things. Method 1: Using a user-defined function and append() function In this method, we will see how to find the largest element ... Read More

Golang program to add elements to a slice

Akhil Sharma
Updated on 17-Jan-2023 11:42:47

1K+ Views

In this tutorial, we will learn how to add elements to a slice using different examples. A slice is a sequence of elements just like an array. An array is a fixed sequence of elements whereas slice is a dynamic array which means its value is not fixed and can be changed. Slices are more efficient and faster than arrays moreover they are passed by reference instead by value. Let’s go through the example to understand things. Method 1: Using append function with strings In this method, we will use append function to add string elements to the slice. ... Read More

Explain the purpose of never type in TypeScript

Rushi Javiya
Updated on 17-Jan-2023 10:13:24

2K+ Views

TypeScript is a type-strict language in which we need to define the type for every variable. Also, we need to define the return type of the function and the types of parameters of the function. The never is also one of type in TypeScript like other data types such as string, number, boolean, symbol, etc. We can use the ‘never’ keyword to make a variable of never type. Users can use the never type when they are sure about any situation that will never occur. For example, we can use the never as a return type when we are sure ... Read More

Explain the different variants of for loop in TypeScript

Rushi Javiya
Updated on 17-Jan-2023 10:04:21

345 Views

In any programming language, we use the loops to execute the same code block repeatedly or multiple times. The loops allow us to write less code to execute the same code block many times. The for loop is one of the loops in TypeScript. As given below, there are also three different sub-types of the for loop in TypeScript. Normal for loop for-of loop for-in loop We will learn about all variants of the for loop in this TypeScript tutorial. Also, we will learn how each type of for loop is different from others. Introduction to normal for ... Read More

Explain the Tuple Types in TypeScript

Rushi Javiya
Updated on 17-Jan-2023 10:01:18

330 Views

We will learn about the tuple types in TypeScript. In JavaScript, an array can contain elements of different data types. Still, as TypeScript is a superset of JavaScript and type-strict language, a TypeScript array can contain only single types of elements. So, the tuple allows us to store elements of the different data types in the TypeScript array. Also, when we store elements inside the tuple, the order of elements is important; Otherwise, the TypeScript compiler can generate an error while compiling the code. Syntax You can follow the syntax below to define the tuples in TypeScript. let sample_tuple: [string, ... Read More

Explain the symbol type in TypeScript

Rushi Javiya
Updated on 17-Jan-2023 09:58:20

6K+ Views

The Symbol is introduced in the last main revision of JavaScript, ES6. The Symbol is a data type. As we use the number, string, or Boolean to create the variables of different data-type, we can use the symbol type to create the Symbol. Using the symbol types has many benefits as it provides more features than other data types. In this tutorial, we will learn about the basics of the Symbol and its different uses of the Symbol. Syntax Users can follow the syntax below to create a variable of symbol data type. let test_symbol = Symbol(); let key_symbol = ... Read More

How to convert string to uppercase in TypeScript?

Shubham Vora
Updated on 16-Jan-2023 15:28:42

4K+ Views

In this TypeScript tutorial, we will learn to convert the string to uppercase. We need to convert every single alphabetic character to uppercase to convert the whole string uppercase by keeping the numbers and special characters as it is. As a beginner TypeScript programmer, maybe a question can arise in your mind what is the need to convert the string to uppercase? Here is the very straightforward answer. Have you ever used the search bar of any website, which shows different results when you search? If yes, search the uppercase and normal strings, which will return the search result. It ... Read More

How to use delete Operator in TypeScript?

Shubham Vora
Updated on 16-Jan-2023 15:26:36

22K+ Views

Have you ever tried to delete the object properties in TypeScript? Then you definitely came across the ‘delete’ operator. In TypeScript, the delete operator only allows deleting the undefined, optional, or any object properties. Also, it returns the boolean values according to whether it deletes the property or not. Below, we will understand the different use cases of the delete operator in TypeScript via different examples. Using the Delete Operator to Delete the Object Properties The main use of the delete operator is to delete the optional properties of an object. We can use the delete keyword as an operator ... Read More

How to round the numbers in TypeScript?

Shubham Vora
Updated on 16-Jan-2023 15:24:16

44K+ Views

In this tutorial, we will learn to round numbers in TypeScript. In TypeScript, the number data types can contain number values with decimal parts, and sometimes, we require to remove decimal part by rounding the number value. For example, if you want to show the progress of something in the application, and you are getting the decimal value of the progress, but you want to show the integer values only, then it is required to round the numbers. Here, we will learn 3 to 4 different methods to round the numbers. Using The Math.round() Method to Round a Number In ... Read More

What is the use of this keyword in TypeScript?

Shubham Vora
Updated on 16-Jan-2023 15:22:55

8K+ Views

The “this” keyword is one of the most used keywords in TypeScript. For beginner TypeScript programmers, it’s complex to understand how this keyword works, but they will learn by the end of this tutorial. In this tutorial, we will learn to use this keyword in TypeScript. Syntax Users can follow the syntax below to use this keyword generally. Users can observe how we can access the variable or invoke the method using this keyword. this.var_name; this.method_name(); console.log(this.var_name); In TypeScript, this keyword refers to the global object if it’s not used inside any class or method. Even if we use ... Read More

Advertisements