programming

push() Method in JavaScript

push() Method in JavaScript

The push() method in JavaScript adds one or more elements to the end of an array. This method modifies the original array and returns the new length of the array. Syntax : array.push(element1, element2, ..., elementN); Enter fullscreen mode Exit fullscreen mode *Example 1.: * const fruits = ["Apple", "Banana"]; fruits.push("Orange", "Mango"); console.log(fruits); // Output: ["Apple", "Banana", "Orange", "Mango"] Enter fullscreen mode Exit fullscreen mode *Example 2.: *How to Dynamically Add Elements Using the push() Method index.html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Fruit List</title> <link rel="stylesheet" href="https://dev.to/sudhanshu_developer/style.css"> </head> <body> <div id="container"> <h2>Fruit List</h2> <input…
Read More
Analyzing Algorithm Time Complexity

Analyzing Algorithm Time Complexity

This section analyzes the complexity of several well-known algorithms: binary search, selection sort, and Tower of Hanoi. Analyzing Binary Search The binary search algorithm presented in BinarySearch.java, searches for a key in a sorted array. Each iteration in the algorithm contains a fixed number of operations, denoted by c. Let T(n) denote the time complexity for a binary search on a list of n elements. Without loss of generality, assume n is a power of 2 and k = logn. Since a binary search eliminates half of the input after two comparisons, Ignoring constants and nondominating terms, the complexity of…
Read More
Understanding the `this` Keyword in JavaScript

Understanding the `this` Keyword in JavaScript

The this keyword in JavaScript can be one of the most confusing concepts for new developers. Its value can change depending on where it is used, making it crucial to understand its behavior in different contexts. This article will demystify the this keyword by exploring its use in various scenarios. What is this? In JavaScript, this refers to the context in which a function is executed. It provides a way to access properties and methods of an object from within the object itself. Global Context When used in the global context (outside of any function or object), this refers to…
Read More
Fui commitar e deu branco. E agora?

Fui commitar e deu branco. E agora?

Esses dias, navegando no X, me deparei com a seguinte imagem E achei engraçado, porque eu e você provavelmente já nos vimos nessa situação: adicionamos os arquivos e ficamos literalmente travados pensando o que colocar de mensagem no commit. Muitas vezes os arquivos são em pastas e contextos diferentes, o que dificulta ainda mais a pensar em uma mensagem condizente. E é aí que mora o problema: Quando commitamos todos os arquivos com o famoso git add . fica muito difícil resumir em uma frase o que foi feito naquele commit. E você no fundo sabe que uma hora ou…
Read More
How to Create a Horizontal Navigation Bar Using CSS

How to Create a Horizontal Navigation Bar Using CSS

In web design, a horizontal navigation bar is a fundamental element allowing users to navigate different website sections. Creating a sleek and functional navigation bar using CSS (Cascading Style Sheets) is relatively straightforward and provides a lot of flexibility in terms of design and responsiveness.Here’s a step-by-step guide to creating your own horizontal navigation bar:Step 1: HTML StructureFirst, let’s set up the HTML structure for our navigation bar. We’ll use an unordered list (<ul>) to hold the list items (<li>) which will represent each navigation link. <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Horizontal Navigation Bar</title>…
Read More
Group Rows and Concatenate Cell Values

Group Rows and Concatenate Cell Values

Problem description & analysis: Here is a categorized detail table: We need to group the table and concatenate the detail data using the semicolon. Solution: Use SPL XLL to do this: =spl("=E@b(?.groups(~1;concat(~2;$[;])))",A2:B9) Enter fullscreen mode Exit fullscreen mode As shown in the picture below: Explanation: E@b function converts the two-dimensional table to a sequence. ~1 represents the first sub-member of the current member; and $[] represents a string. Source link lol
Read More
Vector and Stack Classes

Vector and Stack Classes

Vector is a subclass of AbstractList, and Stack is a subclass of Vector in the Java API. The Java Collections Framework was introduced in Java 2. Several data structures were supported earlier, among them the Vector and Stack classes. These classes were redesigned to fit into the Java Collections Framework, but all their old-style methods are retained forcompatibility. Vector is the same as ArrayList, except that it contains synchronized methods for accessing and modifying the vector. Synchronized methods can prevent data corruption when a vector is accessed and modified by two or more threads concurrently. For the many applications that…
Read More
Explaining ‘this’ keyword in JavaScript

Explaining ‘this’ keyword in JavaScript

1. Global Context When used in the global context (outside of any function), this refers to the global object, which is window in browsers and global in Node.js.console.log(this); // In a browser, this logs the Window object 2. Function Context In a regular function, the value of this depends on how the function is called. a. Function InvocationWhen a function is called as a standalone function, this refers to the global object (in non-strict mode) or undefined (in strict mode). function foo() { console.log(this); } foo(); // In non-strict mode, logs the global object (Window in browsers) // In strict…
Read More
Game Jam Experience();

Game Jam Experience();

A few days before I participated in a jam to showcase my skills and see what other people are building, it was hosted on itch.io a famous place for hosting games and game jams. My Experience: The game jam hosts had given a time period of 10 days to finish a game by either using an engine or a framework.Like always I decided to make a game with pygame and choosing a difficult path for myself which gives more pleasure when completed. I only had last five days due to a work load in the previous days. After thinking a…
Read More
No widgets found. Go to Widget page and add the widget in Offcanvas Sidebar Widget Area.