Posts by Costamilam • 9,556 points
509 posts
-
2
votes0
answers41
viewsQ: How to style components nestled with Shadow DOM?
I have 2 nested web components that use Shadow DOM. The first, my-component, only render the second component: <my-another-component part="my-another-component" /> And the second,…
-
1
votes3
answers576
viewsA: What is CSS OK?
Well is the acronym for Block Element Modifier (Element Modifier Block), is a methodology based on these three entities that deifne nomenclature rules, file structure and code writing Block: A…
-
1
votes1
answer158
viewsA: In terms of user experience, is it impactful to remove accents and special characters from a URL?
The question has two points, an objective, if there is a technical impediment, and a more subjective, the impact on the user experience. Starting with the simplest, there is some technical…
-
2
votes2
answers85
viewsA: How can we not do anything if the suit falls into the fake?
In Javascript there is no type void, then the function, explicitly or not, will return something, if not specified, will be undefined: function example() {} console.log(example()); function…
-
1
votes1
answer136
viewsA: Communication between directives
It is not possible to communicate through events, which would be the most natural way: <div appFather> <button appChild>Child 1</button> <button appChild>Child…
-
1
votes1
answer143
viewsA: Transforming an object into an array
A very basic way is to loop the object to populate an array: const response = { 1: "Julio", 2: "Rubens", 3: "Narciso", 4: "Elton", 5: "Junior" } const array = []; for (const key in response)…
javascriptanswered Costamilam 9,556 -
0
votes2
answers110
viewsA: Is it possible to use Async Generators with the ES5 syntax?
It is possible, simply, through recursion instead of using a loop. I created the function asyncForeach, that receives an iterator and a callback function that will be executed at the end of each…
-
1
votes2
answers86
viewsA: catch all getElementsByClassName with exactly equal class
There are several options: console.log('Modo 1') for (const el of document.body.querySelectorAll(':not([data-full]) > [class="n1 n2 n3"]')) console.log(el); console.log('Modo 2') for (const el of…
-
4
votes2
answers110
viewsQ: Is it possible to use Async Generators with the ES5 syntax?
For example, the code below that creates a async Generator: async function* iterate() { yield 1; yield 2; yield 3; return null; } Could be used with the syntax for await...of: for await (const…
-
4
votes2
answers611
viewsA: What is the purpose of using UUID (version 4) as "Primary key"?
Thinking of any random identifiers, regardless of the pattern, there are some advantages: Is a little more secure, as said, a self-improved internal identifier is much simpler to know where other…
-
0
votes3
answers258
viewsA: How to search for an element with querySelector filtering through innerText?
That’s probably not a good idea... If, in the future, it is determined that it is best for the business to use the word "ball" instead of "ball", and therefore the terms in the applications, the…
-
0
votes1
answer303
viewsA: Unexpected behavior when updating component status
After a few more tests, I discovered the reason, the variable globalState is an object, and therefore is always passed as reference, when updating the value of the substate (Mystate, class inherited…
-
-1
votes1
answer303
viewsQ: Unexpected behavior when updating component status
I’m working on a project with many components, and most of them need to share the same state, do it through props works, but is difficult to maintain, if a child component needs any more value, it…
-
1
votes1
answer39
viewsQ: How does Audiocontext work?
I took a look at MDN, but I didn’t quite understand its functionality... What good is? How to use? What is the difference with Audio? They should be used together? It is necessary, for example, for…
-
2
votes1
answer242
viewsQ: Entering the full screen in iframe makes the page scroll up
I’m creating a page that will be used as an iframe in other applications, to test how it behaved in different sizes, created a page and added several iframes to the page I was making, but with…
-
3
votes2
answers273
viewsA: What is the best way to call the requestAnimationFrame() method?
If the minhaFuncao starts the animation, in the second example, the animation will only start after the page update, not immediately, as in the first example The first view may seem indifferent, and…
javascriptanswered Costamilam 9,556 -
1
votes4
answers823
viewsA: Transform String Array into Object Array
There is no problem with your code, but I would suggest reducing the amount of variables created, if you use the variable only once, it probably doesn’t need to exist. Other than that, your code has…
-
5
votes1
answer224
viewsQ: Is it possible to start serverless-offline by Javascript?
The plugin serverless-offline is used to start a framework-based application Serverless. To start, the command is used serverless offline [options] or sls offline [options] Is it possible to start…
-
0
votes1
answer16
viewsA: Problem with function Undefined return
Missing to return the factorial in your else: else{ res *= n; return fatorial(n - 1); }
-
0
votes2
answers93
viewsA: PHP - doubts with date("Y-m-d")
The way you’re doing it isn’t ideal. With each loop a new date is generated, however, as you are only working with day, month and year, hardly the last date will be different from the first (only if…
-
3
votes2
answers384
viewsA: How to call a function in javascript by Android keyboard enter?
You can use the Keyboardevent, probably the best option is Event keyup, because it will be fired only once even if the user keeps the key pressed. Then just check which key was pressed through the…
-
1
votes1
answer608
viewsA: Cannot find control with name: 'student.id'
To access a control within a group of controls you need to first set the group and then call the control You can use the directive formGroupName that works like the formControlName, but the control…
angularanswered Costamilam 9,556 -
1
votes2
answers1997
viewsA: Replace all letters of a String with asterisks
You can use the method replaceAll passing a regex to replace all letters except space: "Palavra Criptografada".replaceAll("[^ ]", "*"); By your example in the comments, that’s what you want, but if…
javaanswered Costamilam 9,556 -
1
votes3
answers122
viewsA: How to obtain the contents of an HTML element from a Regex string?
You can use the bilioteca jsdom to gain access to a DOM manipulation API, but I can’t tell if it’s native or just simulates native: const jsdom = require("jsdom"); const dom = new…
-
3
votes3
answers101
viewsA: Why am I not able to modify the class of the element with the classList property?
Using the classList, to exchange an element class for ourtra, the replace method must be called, passing the class that must be exchanged and the new one, for example:…
javascriptanswered Costamilam 9,556 -
0
votes1
answer93
viewsA: Javascript - Stop Condition
Your code has some problems: String is a function, when comparing it with the variable dado will always return false The return of expression typeof <variavel> will be a string, and if type is…
javascriptanswered Costamilam 9,556 -
7
votes3
answers598
viewsA: What is the difference between keys and parentheses in an Arrow Function in Javascript?
This has nothing to do with React, JSX or any library or superset (Typescript, for example), are just Javascript syntax: In the second, the keys define the beginning and end of a block of code,…
-
4
votes2
answers59
viewsA: I am clicking on the <Details> or <Summary> element?
First you should know that Javascript events are propagated to the parent elements, that is, when you click on <sumary> you are also clicking on <details>, since the first is the son of…
htmlanswered Costamilam 9,556 -
2
votes2
answers612
viewsA: Mysql + Nodejs, SELECT Return Undefined
That’s because the function sqlQuery has no return, it takes as parameter a callback that will be executed asynchronously, that is, when the query has the result ready, executes the function passed,…
-
0
votes2
answers844
viewsA: Count how many equal names there are within a JSON and display in Nodejs screen
There are several problems in your code, I can’t imagine how it came to this, it seems that mixed several ways to do something similar to what you want I will put a commented solution to understand…
-
1
votes1
answer397
viewsA: This is Undefined in React Hooks
You must receive props as a parameter of hook (just as you get it in the class builder) and use it without the this: function Exemplo(props){ const {id} = props.match.params // ... }…
-
8
votes1
answer64
viewsQ: What is the advantage of implementing the Angular lifecycle event interfaces?
Angular has an interface for each event of its life cycle, for example, OnInit for the method ngOnInit Since it is not necessary to implement such interfaces in order to benefit from the events,…
angularasked Costamilam 9,556 -
1
votes2
answers81
viewsA: How to refactor my method by eliminating the setTimeOut that is controlling the life cycle?
To use the data received by the component you must wait until the event afterViewInit, only from it the data will be set in your class, in ngOnInit will not yet be available because it comes before…
-
1
votes1
answer46
viewsA: Problem with Function Return, even returning false runs
The function usuarioExiste is asincrona, ie, your return is not a boolean, but rather a Promise<boolean>, then you need to wait for the promise to be long so make the check, you can do this…
-
4
votes2
answers928
viewsA: How to hide Axios request data in Javascript (JS Node)
Not... If you need to pass all this data from the client to the server in order to register the user (or do anything else), the client will at some point need this data, there is no way to hide it…
-
1
votes2
answers55
viewsA: How can I receive all values that correspond to a search list
You can swap the comparison for a check if the id index in the array is different from -1 (which is the return in case there is no): console.log([1,2,3].indexOf(1) != -1)…
javascriptanswered Costamilam 9,556 -
1
votes2
answers1285
viewsA: How to define private attributes in a constructor function using javascript
A private property of a class is a variable that can only be accessed by it, right? So the variables nome, idade and cor are already private, since only exist within the function, if you want to…
-
1
votes1
answer30
viewsA: Return different from desired in function
On the line return $sql->execute(); you return the query execution and therefore nothing runs after that. Remove the keyword return and add it at the end of the function followed by the variable…
phpanswered Costamilam 9,556 -
2
votes1
answer32
viewsA: Call bindValue for $this->... or direct for $_SESSION?
It depends on how it was done, if, when defining the variables in $this, did not go through any process of sanitization, validation, etc., from the point of view of safety is the same, after all,…
-
1
votes1
answer53
viewsA: In regular expressions in . htaccess, what does this rule mean?
The line of RewriteCond is a condition for the execution of the next line The line of RewriteRule creates a variable with the name REWRITEBASE and value /, you can access it using…
-
0
votes1
answer38
viewsA: Ionic call Function inside callback
Switch the callback to a Arrow Function (() => {}), thus, the this will reference the location where closeGPS() is and then call her with the this navigator.geolocation.getCurrentPosition((local)…
-
0
votes1
answer155
viewsA: Interaction between Threads in Python, error message " Object is not callable"?
In doing Thread_Via_N = Thread(...) the variable with that name becomes the object returned by the function Thread, instead, use another variable: x = 4 while x > 0: tmp =…
-
1
votes2
answers225
viewsA: Logic test inside the Python array
It is not possible, because if the condition is not satisfied, what would be the value returned? There needs to be a return. But if there is a second value if the condition is not met, it can be in…
-
1
votes2
answers85
viewsA: How to create a property in a Javascript method
What happens in the querySelector is that it returns an object (actually the reference) and therefore you have access to several properties function foo() { return { bar: 'r', baz: 'z' }; }…
-
5
votes1
answer516
viewsQ: What is the difference between an Entity and a Model (MVC and the like)?
In object orientation both are classes usually used to represent something that will be persisted (not that it is mandatory to persist), but what is the difference between them? Or are they…
-
2
votes3
answers74
viewsA: How to activate only the next div?
Use $(this).next('.panel') in place of $(".panel"). This will cause the next one to be accessed panel relative to the element clicked, instead of selecting all…
-
12
votes2
answers623
viewsQ: How to publish a Typescript library on NPM?
I set up the package.json with the properties main and types: { "name": "idb2promise", "version": "0.0.5", "description": "TypeScript library to manage IndexedDB Storage", "main": "./dist/index.js",…
-
3
votes1
answer32
viewsA: Sum variable within FOR
Just create a variable before and add to each iteration: $total = 0; for($n=1;$n<= 26;$n++){ $quant_enc = "SELECT * from presenca WHERE data_presenca = '$ano-$mes-$n' GROUP BY id_cad"; $ex_enc =…
-
0
votes1
answer57
viewsQ: How to fix typescript types in Service Worker?
I have a Typescript file that will be used in Service Worker, but by default, the scope/context/this global and variable self file will always reference to Window type, which is not what happens at…
-
1
votes1
answer134
viewsQ: How to use Dynamic Links with the <projectID>.web.app domain?
I have an application hosted using a Hosting Service subdomain, this application also uses Dynamic Links It is possible to use a path, for example, /share/<link> in the same application…