Found 26504 Articles for Server Side Programming

How optional chaining works in TypeScript?

AmitDiwan
Updated on 16-Feb-2023 15:08:00

401 Views

In this article, you will understand how optional chaining works in TypeScript. Optional chaining operator (?.) accesses an object’s property. If the objects property is null or not defined, it returns ‘undefined’. Let us first understand what TypeScript is. Strongly typed programming language TypeScript, which is based on JavaScript, gives you better tools at any scale. Code written in TypeScript can be converted to execute in any JavaScript-compatible environment. JavaScript is understood by TypeScript, and type inference is used to provide excellent tooling without the need for additional code. Example 1 In this example, we use the optional chaining operator ... Read More

How to communicate JSON data between C++ and Node.js ?

Shubham Vora
Updated on 16-Feb-2023 15:51:20

2K+ Views

C++ is a powerful, high-performance language widely used for system-level programming and applications. At the same time, Node.js is an open-source, cross-platform JavaScript runtime environment commonly used for web applications. By understanding the various methods for communicating JSON data between C++ and Node.js, developers can choose the best approach to their specific needs. In this tutorial, we will explore the various ways to communicate JSON data between a C++ application and a Node.js server. Three common approaches: using a RESTful API, using a message queue, and using a WebSocket Users can follow the steps below to communicate JSON data between ... Read More

Golang program to replace a character at a specific index

Akhil Sharma
Updated on 13-Feb-2023 15:46:44

2K+ Views

In this tutorial, we will inculcate how to replace a character at a specific index using few examples. The output will be printed on the console using fmt.Println() function. Let’s dive deep into the examples and see how it’s done. Method 1: Using Replace Function In this method, we will learn how to replace a character at a specific index using replace function. The output is printed on console using fmt.Println() function. Let’s understand this through the code. Syntax func Replace(str, oldstr, newstr string, m int) string This function is used to return the copy of the string which ... Read More

Golang Program to remove all 'nil' elements from the array

Akhil Sharma
Updated on 13-Feb-2023 15:44:10

2K+ Views

This tutorial is all about how to remove all nil elements from the array. Basically, sometimes there are empty strings present in the array which we want to remove. Here in this tutorial, we will have a look how to remove those strings with the use of very simple methods. Method 1: Using helper Function Approach In this method, we will see how to remove null elements using helper function approach. The array will be taken as a parameter in the function and the output will be printed on console using print statement of Golang. Syntax func append(slice, element_1, element_2…, ... Read More

Golang program to iterate over a Slice

Akhil Sharma
Updated on 13-Feb-2023 15:38:02

3K+ Views

In this tutorial, we will iterate over a slice using different set of examples. A slice is a dynamic sequence which stores element of similar type. The iterated list will be printed on the console using fmt.Println() function. Method 1:Using for Loop with Index In this method, we will iterate over a slice using for loop where both the index and its element will be printed on the console screen. Let’s have a look how to execute this example. Algorithm Step 1 − Create a package main and import fmt package in the program. Step 1 − Create a package ... Read More

Golang program to fill an array with a specific element

Akhil Sharma
Updated on 13-Feb-2023 15:35:44

2K+ Views

In this tutorial, we will learn how to fill an array with a specific element. We will explore few examples to know more about this program. The output will be printed on console using fmt.Println() function. Let’s have a look and understand the program. We have used the following make() function in the examples. Syntax func make ([] type, size, capacity) The make function in go language is used to create an array/map it accepts the type of variable to be created, its size and capacity as arguments. Method 1: Using for Loop and Make Function in Main Function ... Read More

Golang program to find the prime numbers from the array

Akhil Sharma
Updated on 13-Feb-2023 15:31:52

504 Views

In this tutorial, we will showcase how to find the prime numbers from the array using different examples. Prime numbers are those numbers which are either divisible by 1 or by themselves they have no factor other than this. Now we will present you few illustrations to help you get clear with the logic behind this program. Method 1: Finding Prime Number in the main Function In this particular method, we will print the prime numbers with the help of nested for loops. We will half the array elements in every inner iteration and check whether they are divisible or ... Read More

Golang program to fetch elements from an array based on an index

Akhil Sharma
Updated on 13-Feb-2023 15:26:59

893 Views

In this tutorial, we will learn how to fetch elements from an array with the help of index using different examples to showcase what methods can be applied to it and the result obtained will be printed on the console using the print function in Golang. Method 1: Using an Array Index In this method, we will see how to fetch element from an array using index in for loop and this is one of the simplest methods to solve this problem, lets have a look at this example to understand it. Algorithm Step 1 − Create a package main ... Read More

Golang Program to remove given element from the array

Akhil Sharma
Updated on 13-Feb-2023 15:25:24

4K+ Views

In this tutorial, we will learn how to remove an element from an array using simple for loop approach. The logic behind this approach is that create a new array and the particular index element which is to be removed don’t add it to the new array. Let’s have a look how to execute it with the use of different examples. Remove Element from the Array in main Function In this method, we will execute the entire program inside main function. An original array and a new array will be created to execute the removal of elements from the array. ... Read More

Golang program to illustrate the creation of strings

Akhil Sharma
Updated on 13-Feb-2023 15:21:26

174 Views

In this tutorial, we will see how strings are created in Golang. There are different ways to create strings which we will learn via some examples. In Golang a string is a sequence of variable-width characters where each character is represented by one or more bytes. Method 1: Using double Quotes with Shorthand Declaration In this method, we will learn about how to create strings using shorthand declaration. Let’s dive into the code to understand it. Algorithm Step 1 − Create a package main and import fmt package in the program. Step 2 − Create a function main and further ... Read More

Advertisements