Get Substring in TypeScript

Shubham Vora
Updated on 03-Jan-2023 11:51:17

721 Views

The string contains various characters, and the substring is the part of the string. We can get the substring from the string two ways. The first is using the starting and ending position of the substring, and the second is using the starting position and length of the substring. We will learn both ways to get the substring from the string in TypeScript in this tutorial. Get The Substring Using The Start Position and End Position In TypeScript, indexing of string starts from zero. So, if we have a zero-based starting and ending position of the substring, we can get ... Read More

Find Natural Logarithm of a Number in TypeScript

Shubham Vora
Updated on 03-Jan-2023 11:48:34

630 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

Create an Array of Objects in TypeScript

Shubham Vora
Updated on 03-Jan-2023 11:46:04

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
Updated on 03-Jan-2023 11:39:00

556 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

Find Last Occurrence of Element in Array in TypeScript

Shubham Vora
Updated on 03-Jan-2023 11:33:46

3K+ Views

We will learn to find the last index of the element in the array in TypeScript. In development, an array of the data can contain duplicate data, and we may need to keep the last occurrence of the element. For example, we have fetched all users’ login history from the database. Now, we want to find when particular users were logged in for the last time. In such scenarios, we can use the below methods to find the last occurrence of the element in the array. Search from the last in the array To find the last occurrence of the ... Read More

Aborting a Shell Script on Command Failure

Satish Kumar
Updated on 03-Jan-2023 11:10:33

14K+ Views

Overview By utilizing Bash scripts, we can have access to a powerful programming language. Writing such scripts is an efficient way to run several commands one after the other. Even if one command fails, the others will still be executed. We’ll learn how we can add some safeguards so that these errors don't happen. The example code has been tested in Bash. They should also work for other POSIX-compatible shell environments. The Problem Let’s first take a look at how Bash handles error messages by default. Let's say we have a simple shell script called "hello.sh" which prints out the ... Read More

Working with Zip Command in Linux

Satish Kumar
Updated on 03-Jan-2023 11:09:03

3K+ Views

Overview The zip command is one of the most useful tools available on any operating system. It allows you to compress multiple files into a single compressed archive file. You can then decompress that archive file using the unzip command. This tutorial will show you how to use the zip command to create and extract archives. In this tutorial, we’ll be looking at the zip command-line tool in Linux. We will learn how to use it for creating and extracting archives. The zip command is a part of the GNU core utils package. It can be used to create and ... Read More

Killing All Members of a Process Group in Linux

Satish Kumar
Updated on 03-Jan-2023 11:06:59

1K+ Views

Overview As a Linux system administrator, dealing with processes is a frequent task. Generally, they're easy to stop, however in certain cases - when there are large numbers of processes within the same groups - additional steps might be needed. We’ll take a closer look at how to manage processes using the concept of “groups”. Also, how to terminate all processes that belong to one particular group. Process Groups A process grouping in Linux is a way that Linux processes share the same PIDs (process IDs). They are a set of related processes that share the same PIDs. Killing the ... Read More

Create a File of Certain Size in Linux

Satish Kumar
Updated on 03-Jan-2023 11:05:00

25K+ Views

Overview When using Linux, we often perform various operations on our own personal data. One common operation is to create an empty file of a specific size. There are many ways or command to achive this, here we’ll cover some of these methods − “dd” command dd − The dd command is a utility for copying files and converting the format of data. It can be used to create a file of a certain size by specifying the block size and the number of blocks with the bs and count options, respectively. The dd command reads data from an input ... Read More

HTTPS Connection Using cURL on Linux

Satish Kumar
Updated on 03-Jan-2023 11:03:08

7K+ Views

Overview curl is a command line tool that supports many different types of websites including https sites. It can be used to connect to any website, but it's most commonly used for connecting to web servers and retrieving data from them. In this tutorial we will learn how to use curl to make an HTTPS connection to a website. We will also see how to retrieve the contents of a file using curl. We’ll look at using curl to call an HTTP endpoint via HTTPS. What is Curl? Curl is a command line tool that allows users to transfer data ... Read More

Advertisements