Most voted questions
150,413 questions
Sort by count of
-
6
votes3
answers153
viewsWhat is the way to check and react to a change of state of an array using pure Javascript?
I’m studying about the pattern Observer where in an example done in Java it was demonstrated that an X class any called a specific method Y and this called methods updateof the observers, that is to…
-
6
votes5
answers96
viewsMatrix with out-of-range index returning correct values
I was trying to create a matrix using while and realized that the program displays all the elements correctly if I just increment the value of j (column) up to 8. The program was not supposed to…
-
6
votes2
answers52
viewsHow to allow the click event to be ignored by clicking inside an element?
I have a div which contains some child elements. I would like you to click on the window, that one div be removed. The code below served, however, by clicking on the content inside the div, she…
-
6
votes1
answer61
viewsWhy in MOS 6502 the SBC subtracts 2 instead of 1 the first time?
I am trying to learn Assembly for MOS 6502 and I came across unusual behavior when testing my code on online emulator. Code LDA #$5 ; A=5 SBC #$1 ; A=3 mas deveria ser 4 SBC #$1 ; A=2 mas deveria…
-
6
votes1
answer68
viewsAre Java enumerations anti-performance?
In a project I thought of exchanging whole ones for enumbut a colleague told me that enums are anti performatic.
-
6
votes2
answers47
viewsIs it possible to discriminate unstructured values of an object with union type in Typescript?
I realized that by performing the breakdown in the signature of the function (funcao({ a, b }: Objeto)), I end up losing a certain consistency of the types. In the specific case where I realized…
-
6
votes1
answer107
viewsHow does the use of "Set" to remove repeated values from an array in Javascript work?
Is it known almost general which, in Javascript, can be used this trick with Set and Operator spread for remove values duplicates of an array: const arr = [1, 1, 1, 2, 2, 3]; const deduped = [...new…
-
6
votes1
answer85
viewsWhat’s the difference between mod and Rust?
I understand the workings of the keyword mod, explained in this matter. For users of Python, mod works exactly like the keyword import. That is, to use functions and other objects defined in a file…
-
6
votes1
answer115
viewsWhy should we interrupt the Promises current in recursive functions in Javascript?
I will exemplify with codes. I have an asynchronous function called delay which receives a time in seconds and which returns a Promise. It serves to provide a waiting time in seconds: // padrão de 1…
-
6
votes1
answer336
viewsWhat is BFF (Back-end For Front-end)?
This is a term that I have come across several times and I recently saw that this term was cited as a requirement for a job vacancy for a junior dev. I don’t know if that would be absurd, to demand…
terminology software-engineering software-architectureasked 3 years, 5 months ago Cmte Cardeal 5,299 -
6
votes1
answer130
viewsWhat is the difference of syscall and call in Assembly?
The following simple code I wrote, based on a code I read in a book, was not compiling: ;myhello section .data msg db "Boa tarde",0 NL db 0xa section .bss section .text global main main: push rbp…
-
6
votes2
answers112
viewsWhen is an Slice data copied?
When I do so: a = [ 1, 2, 3] b = a[1:] b use the same list of a or it creates another list and copies the data that is pertinent? If you have many items it will slow down? Happens even if I don’t…
-
6
votes1
answer102
viewsHow does . pipe() work on Node.js?
I have a question about how the .pipe(). I saw videos and read the documentation, but I’m not sure how it works. From what I understand, he basically takes the information from a readableStream and…
-
6
votes2
answers229
viewsIf Python strings are immutable, how can we change them with the replace() method?
If Python strings are immutable, how can we change them with the method replace(), for example? Ex: s = "banana" s = s.replace("b", "z") print(s) # zanana Is this a change of the original string or…
-
6
votes2
answers156
viewsWhat are the principles of the dependency injection mechanism?
It has been a while since I try to understand the injection mechanism of dependency and its main essence, however, it does not enter my mind, maybe it is by not understanding the fundamentals and…
software-engineering dependency-injection language-independentasked 3 years, 7 months ago gato 22,329 -
6
votes1
answer79
viewsWhat is the difference between the function "malloc()" and a created variable?
I was reading some codes in C and I realized that to generate some specific object is used the function malloc(). It is not easier to create this object in a variable than to use the malloc()? Here…
-
6
votes2
answers48
viewsHow to create a View with 2 tables with different columns in SQL?
I have the following query: CREATE OR REPLACE FORCE VIEW "Resumo_vendas" ( "TIPO_REGISTRO" ,"VLR_DESCONTOS" ,"VLR_ACRESCIMOS" ,"VLR_PIS" ,"VLR_COFINS" ,"VLR_ICMS" ,"DTA_EMISSAO_NOTA" ) AS ( SELECT 1…
-
6
votes1
answer348
viewsHow to check if a year is leap in Java?
How to know if the current year - indeed, if any year - is leap? Since I can have only the numerical value of the year, or an object representing a date (i.e. Date, Calendar, LocalDate, etc), the…
-
6
votes2
answers155
viewsIs there any way to prevent the use of "new" in a Javascript function?
Assuming the function: function foo() { return 'something'; } It is possible to invoke it (abstract operation [[Call]]): // Invocando `foo`: foo(); In the above example, the string would be returned…
-
6
votes2
answers114
viewsWhat are "fancy words" (fancy words) in programming languages?
First of all, I don’t know if it’s a concept restricted to languages like Typescript or Javascript, so I assume it’s general purpose. I came across the following codes that I will use as an example…
language-independentasked 3 years, 8 months ago Cmte Cardeal 5,299 -
6
votes3
answers90
viewsGroup array of emails by domain of each email in Javascript
I have an array of emails: emails = [ "[email protected]", "[email protected]", "[email protected]", "[email protected]" ] I am using regular expressions to parse domains, and my intention is to…
-
6
votes1
answer93
viewsWhat are the main types accepted by the Fetch API for the HTTP request body?
I know I can use the API fetch to perform HTTP requests by browser. And I know I can use the property body to configure the body of the request. But I would like to better understand which types I…
-
6
votes3
answers142
viewsMultiple cases on switch with C# 8
On seeing this question about multiple conditions in the switch, reminded me of a problem I had and I couldn’t solve. In C# 8, a new syntax for switch: int num = ObterUmNumero(); var descricao = num…
-
6
votes2
answers218
viewsAlternative to __filename and __dirname in Node.js with Ecmascript Modules
From more recent versions of Node.js, you can use the Ecmascript Modules standard (instead of the ancient Commonjs) for importing modules via extension .mjs or field type defined as module in the…
-
6
votes2
answers135
viewsIs it possible to delete previous commits and only remain the current one?
While I was modifying the profile README, I ended up making many attempts and solving some errors, it generated me 90 commits in a single file. I wonder if you can delete all the previous commits…
-
6
votes2
answers144
viewsHow does changing the prototype of the String.prototype.toString() method affect this code in Javascript?
I couldn’t understand why the method reverse is applied in the string "abcde" (over-written in toString) and not in "12345". String.prototype.reverse = function() { return…
javascript string characteristic-language objects prototypeasked 3 years, 9 months ago vncsbraga 61 -
6
votes1
answer144
viewsWhat is the Join() function for in the threading module?
I’ve seen the function join() for the module threading, but I didn’t quite understand what she does.
-
6
votes1
answer107
viewsWhat are the advantages and disadvantages of encapsulated errors types like "Result"?
I’m learning Rust and one of the things that made me curious is the absence of exceptions. Unlike languages such as C#, Java, Javascript, etc., which have exceptions, in Rust this does not exist. If…
-
6
votes1
answer99
viewsWhat are the differences between String.prototype.match and String.prototype.matchAll methods?
Historically, Javascript relies on the method String.prototype.match to perform, for example, string searches through a pattern via regular expression. However, starting with Ecmascript 2020,…
-
6
votes4
answers3540
viewsHow to count occurrences of a letter in a sentence?
I’m trying to do an exercise whose goal is to know how many times a certain letter appears in the sentence, I was trying to do so: var frase = "o homem é o lobo do homem"; var letra = "o"; for (var…
-
6
votes1
answer132
viewsWhat are algebraic data types (algebraic data types or Adts)?
Eventually I read in some articles related to functional programming the term algebraic data types, but I don’t really know what they are and I end up getting a little lost. What are algebraic data…
terminology typing functional-programming type-theory algebraic-typesasked 3 years, 10 months ago Luiz Felipe 32,886 -
6
votes1
answer124
viewsWhy is the "in" method for checking if an element belongs to a collection so slow?
I was having a lot of difficulty executing code efficiently and found that the problem was on a line that used the operator in. Then I created a new function that searches for a match in the list of…
-
6
votes3
answers194
viewsWhy does isNaN(null) return "false"?
I came across a situation where undefined and null return a different value to the function isNaN, while I hoped they would both return true (are not numbers). In the example below I also put a…
javascript characteristic-language numbers ecmascriptasked 3 years, 10 months ago Rafael Tavares 4,528 -
6
votes1
answer57
viewsWhy can a double var store an int type?
Why a var of the kind double can store a var of the kind int? Using C# int x; double y; x = 5; y = 2*x; Console.WriteLine(x); Console.WriteLine(y); Console.ReadLine();…
-
6
votes5
answers1031
viewsCheck that all items in the list are equal
I have a list of times containing the values of times of several cars and I would like to know how do I know if all these values are equal I thought to compare each value with its later, ie compare…
-
6
votes4
answers310
viewsWhat is the MQTT protocol?
These days I’ve heard of a communication protocol called MQTT. For me it sounded like news and I would like to ask some questions: What is the MQTT? He uses TCP? It has some difference in relation…
-
6
votes2
answers187
viewsHow does regular expression with double range work?
I am studying regex and had a doubt when dealing with the range operator (-). I understand a creak like [a-z] means "the whole alphabet in lowercase letters" and that a range like [^A-R]it would be…
-
6
votes1
answer283
viewsGIT LOG: How do I search for a commit through a specific message?
I wonder if there’s any way to use the git log to list commits, filtering through a specific message. Example: git commit -am "Correção do ícone de exclusão na listagem de usuários" In the above…
-
6
votes1
answer66
viewsA subset language of a context-free language is decidable?
If we have a context-free language L and L' is a subset of L, then L' is decidable?
-
6
votes1
answer83
viewsDisplay conditional text snippet with regex
I am trying to create a dynamic text "generator" that will replace patterns with data from an array using regex, the structure is as follows: Hello, [user], your registration was made in…
-
6
votes1
answer125
viewsDifferences between defining object methods using Arrow Function and Function Expression
About "flammable" methods outside objects, I can say that these three forms below act in the same way within my code? Examples: var barquinho = { pedro: () => { console.log("a"); }, tiago:…
-
6
votes3
answers246
viewsWhat is the point of using scripts in links?
I recently saw on the website of W3schools the ability to execute Javascript code in links, placing scripts within the attribute href: <a href="javascript:alert('Hello World!');">Execute…
-
6
votes3
answers146
viewsHow to use double quotes in a python application by running a subprocess
I’m trying to add a new wifi network via command line in a Raspberry Pi, however when I pass the string containing the data of the Wifi network the quotes that should be between the login name and…
-
6
votes3
answers259
viewsWhich means an "!" exclamation before a string inside an if in C#
Hello, I have a question regarding some "snippets" of a program I am using to "study", the question is, what is the meaning of "!" inside an if before a string, I saw some topics on the site…
-
6
votes3
answers758
viewsRandom choices in a Javascript array
Whoa, guys, I’m new to both stackoverflow and JS! Next, I’m having trouble making a script that chooses a string within an array I wrote the code as follows: let choices = ['a', 'b', 'c']…
javascriptasked 4 years, 3 months ago Elias Oliveira 178 -
6
votes1
answer259
viewsCreating regular expressions with a dynamic pattern is problematic? If so, is there a way to avoid the problem?
Let’s say, for some reason, I need to create a regular expression that has a part of its standard configurable by a user. Something like this very trivial example: const regex = new RegExp('^' +…
-
6
votes1
answer196
viewsThe dollar ($) does not work to interpolate a string in Javascript
I’m using a code that uses the dollar sign ($) Javascript, only when using the cipher it gives error in the console and the code to fetch the data of an API ends up not working. What I need to do…
-
6
votes1
answer657
viewsWhat is and how does the "clamp" function work in CSS?
Recently I’ve seen some people talk about the function clamp. What is its real usefulness? Is there any relation to other functions, such as max or min?…
-
6
votes1
answer348
viewsDifference between constructor and function that returns literal object
What is the practical difference between me creating a construction function in this way: function construtora (nome, sobrenome) { this.nome = nome this.sobrenome = sobrenome } Or in this way:…
javascript function characteristic-language objects builderasked 4 years, 5 months ago Gustavo Paiva 173 -
6
votes2
answers273
viewsWhy does pointing to the same memory address change an object?
If I run the following code: let a = [1, 2, 3] let b = a In this case, the variable 'a' and 'b' are pointing to the same memory address, consequently, everything I change to 'a' will theoretically…