Exports and Imports in JavaScript

AmitDiwan
Updated on 16-Aug-2023 15:55:32

385 Views

We will learn how to utilise imports and exports in javascript in this post, as well as how to use them to break our code into different modules in order to better organise it. To facilitate modular development in programming, which enables us to organise our code into reusable modules, JavaScript provides exports and imports. To achieve this sharing and reusability of code, we can use different types of exports and imports. Exports allow us to make functions, variables, objects, or any values available outside of a module. By marking components as exports, we can expose them for use in ... Read More

Check Duplicate in a Stream of Strings

Tapas Kumar Ghosh
Updated on 16-Aug-2023 15:53:12

480 Views

The stream of strings is a sequential flow of given data where an individual element of the stream represents a string. The stream allows a large process of string data In C++, we have some STL(Standard template library) based functions such as count() and insert() to Check duplicate in a stream of strings. Using Standard Template Library The program uses C++ STL to set the header file unordered representing the unique key element and helps to solve the duplicates in a stream of strings. Syntax The following syntax is used in the examples- static unordered_set unq_string; The ... Read More

Various Ways to Define a Variable in JavaScript

AmitDiwan
Updated on 16-Aug-2023 15:42:52

849 Views

In this article, we will learn about the various ways to define and declare variables in javascript, and how we can use them to implement state management in our applications. In javascript, variables can be thought of as containers that hold values, and which can be retrieved later on in the application. There are several ways to define a variable, each with its own syntax and use cases. Let’s understand different methods of doing so with the help of some examples to understand the concept better. Example 1: Using the var keyword The “var” variable has function scope, which means ... Read More

Read a Cookie Using JavaScript

AmitDiwan
Updated on 16-Aug-2023 15:40:37

5K+ Views

In this article, we will learn how to read cookies in javascript, and how we can use it to implement certain features such as user tracking, user preference, personalized experience, etc. Cookies are small pieces of data stored in a user's web browser. In javascript, we can read cookies using document's cookie property and extract the desired information using destructuring. Let’s look at some of the examples to understand the concept better − Example 1 - Reading All Cookies In this example, we will − read all cookies by accessing the document.cookie property and log them to the console. ... Read More

Function Returning Another Function in JavaScript

AmitDiwan
Updated on 16-Aug-2023 15:37:40

697 Views

In JavaScript, functions can be assigned to any variables, they can be passed as arguments to other functions, and can even be returned from other functions. This behavior of functions allow us create HOCs in javascript, which are functions that return other functions. These higher−order functions can be used in various applications like callback functions, function memoization, or transformation, etc. In this article, we will learn functions returning another function, aka higher−order functions in javascript, and how we use them to implement certain javascript features like callbacks, array/object filtering and transformations, etc. Let’s look at some of the examples to ... Read More

Find Keys with Specific Suffix in Dictionary using Python

Tapas Kumar Ghosh
Updated on 16-Aug-2023 15:37:38

415 Views

The suffix of keys is a group of letters that is mentioned at the end of the word. In this problem statement, we need to create the specific variable that set the suffix key to filter the result by using some specific conditions. In Python, we have some built-in functions such as endswith(), filter(), lambda, append(), and, items() that will be used to Find Keys with specific suffix in Dictionary. Let’s take an example of this. The given dictionary, my_dict = {'compiler': 100, 'interpreter': 200, 'cooperative': 300, 'cloudbox': 400, 'database': 500} The suffix key is set to er, ... Read More

Check Substrings for Vowels vs Consonants

Tapas Kumar Ghosh
Updated on 16-Aug-2023 15:35:35

265 Views

In Alphabetical series there are consists of 26 characters of which 5 characters are vowels such as a, e, i, o, u and the rest are called as consonants. In C++, we have predefined functions such as tolower() and length() that will help to Check whether all the substrings have number of vowels atleast as that of consonants. Let’s take an example of this. The string has only one consonant with the rest vowel “aiteau”. Hence, it is accepted as the final result. The string has more than one consonant with the rest vowel “appioa”. Hence, it is not ... Read More

Interconvert Tuple to Byte and Integer in Python

Tapas Kumar Ghosh
Updated on 16-Aug-2023 15:34:13

1K+ Views

The tuple is ordered or a finite sequence to collect the data. It can be represented by using parenthesis i.e. (). A byte integer is a simple number without having decimal or fractional values. In Python, we have some built-in functions such as from_bytes(), bytes(), unpack(), and, enumerate() will be used to Interconvert Tuple to Byte Integer. Syntax The following syntax is used in the examples from_bytes() The from_bytes() is an in-built function in Python that accepts two specific parameters bytes()- The bytes() is also a built-in function that defines the immutable series of integers. byteorder- The byteorder ... Read More

Convert Array to Set in JavaScript

AmitDiwan
Updated on 16-Aug-2023 15:33:12

765 Views

This tutorial will teach you how to eliminate duplicate values from an array of items in Javascript by converting an array to a set. When storing distinct values from a collection of data in javascript, we can utilise the Set data structure to get rid of duplicate values. When we wish to eliminate duplicates from our data or take advantage of the special features offered by Sets data structure, converting an array to a Set can be helpful. Let’s look at some of the examples and methods to understand the concept better − Example 1 - Using the Set Constructor ... Read More

Index Match Element Product in Python

Tapas Kumar Ghosh
Updated on 16-Aug-2023 15:32:51

484 Views

The Index match element Product refers to two different lists where it contains the elements and set to respective variable. If common matches are found, then it filters the element by multiplication. To solve this problem statement, Python has some built-in functions such as range(), len(), zip(), prod(), reduce(), and, lambda(). Let’s take an example of this. The given input lists: list_1 = [10, 20, 30, 40] list_2 = [10, 29, 30, 10] So, the common matches found in indexes 0 and 2 and its product become 10*30 = 300. Syntax The following syntax is used in the examples ... Read More

Advertisements