Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Posts by hkotsubo
I wouldn't use grep. As the other answers already said, it's not the right tool for this job. Considering your specific case (fields separated by /), basename is the most straighforward way, as st...
Instead of replacing the brackets, you could do just one loop, and keep a stack with the opening brackets. Every time you find a closing bracket, check if it corresponds to the stack top: if it's n...
Yes, it's possible. In a more general way, every recursive algorithm can be converted to an iterative one (and vice-versa). You just need to use a stack. Internally, a recursive function will use...
Does a for...of loop must contain a variable without assignment sign (=) Yes. and why? Because that's the syntax defined by the language specification. The people who defined it decided ...
any DOM "tree" node is actually a "branch" Not exactly. Document Object Model and Nodes According to the MDN documentation, the DOM (Document Object Model) is "the data representation of the...
How does storing replaced strings in the node variable makes a change in the text appearing to the end user? In your case, you're changing the textContent property. When accessed, it returns t...
Code blocks inside comments are hightlighted only if I'm on the comment's thread page. If I view it on the post itself (after expanding the respective thread), it's not highlighted. Example: in ...
I personally think its syntax is confusing. Well, it's just a matter of getting used to it, I guess :-) Anyway, this code is just looping through all childNodes and in each iteration it cal...
How this recursive treewalker works? To understand what the code does, we need to first see what problem it's trying to solve and why it needs to be solved this way. Let's consider this HTML:...
At the documetation you linked, if you click on "which will clear the document", it'll go to the documentation for document.open, and that page says in the beginning: All existing nodes are remo...
The basic ideia is to create an input with a "fake" placeholder, and a span that will serve as the actual placeholder text. Then you group both inside a label, like this: <label> <inpu...
TL;DR To count the number of li items, just do: console.log(document.querySelectorAll('ul.example > li').length); That's all, no need to complicate with filter.call (but I'll explain that t...
Assignment (=) = is the assignment operator: it assigns a value to "something". One important detail is that an assignment expression not only assigns a value, but it also returns it. This allows...
I've got a HTTP Error 500 when trying to access this post. Here's the quote error ID's: ef4f6ec1-8d0f-4be3-9553-36e01b5f01c4 and bbeb9bf9-2c58-43b1-be05-c9e914bb80bf. I've browsed to another pos...
When posting this question, I noticed a difference between editor's preview and the post's final render. When editing, the preview correctly shows the Zalgo Text: But after the post is saved, i...
tl;dr The purpose of addEventListener is to define what happens when an event is triggered at some element. But it also allows us to implement event delegation, due to the bubbling/propagation beh...
void (*ptr)() defines a function pointer. It says that ptr is a pointer to a function. But that function must have a void return type, and take an arbitrary number of parameters (that's what the em...
There are many ways to get the previous states of HEAD, and which one to use will depend on each situation. Git keeps reference logs (also called "reflogs"), that "record when the tips of branch...
One solution is to create a method in the enum that takes a String and converts it to the correspondent value. Then we annotate this method with @JsonCreator: import com.fasterxml.jackson.annotati...
Based on the code snippet in the question (which uses collect etc), I'm assuming you want to use streams. I'm also infering that "empty values" means those values for which Optional.isEmpty() retur...
The problem described below occurs in Windows 10 and Chrome 87.0.4280.66 (64 bits, JavaScript enabled). I could post this question only in mobile (Chrome/iOS 14.2), where the problem doesn't occur....
The solution proposed by the other answer works, but there's a corner case. If the last message is shorter than the previous one, you might not get what you want. Example: print("this is some text...
You're getting close, just need a few adjustments. Instead of using the hostname property, I prefer to use host, because it also includes the port (in case the URL has one) - check the documentati...
Is it better to use static method? I don't like to think of static (or any other language feature/mechanism) in terms of bad/worse and good/better (although I do that too, I constantly try to ...
After I wrote this answer, I could notice that, when there's inline code in the last line of a paragraph, sometimes the border-bottom of the inline code text is not displayed. One case is when the...
- ← Previous
- 1
- 2
- 3
- 4
- Next →