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.
Post History
Credit for User:Meriton for developing the following code (first published here): function replaceIn(e) { if (e.nodeType == Node.TEXT_NODE) { e.nodeValue = e.nodeValue.replaceAll("a", "");...
#3: Post edited
- Credit for [User:Meriton](https://software.codidact.com/users/53280) for developing the following code ([first published here](https://software.codidact.com/posts/286304/286317#answer-286317)):
- ```javascript
- function replaceIn(e) {
- if (e.nodeType == Node.TEXT_NODE) {
- e.nodeValue = e.nodeValue.replaceAll("a", "");
- } else {
- for (const child of e.childNodes) {
- replaceIn(child);
- }
- }
- }
- replaceIn(document.body);
- ```
- Is it possible to get essentially the same recursive behavior without a procedure which calls itself?
Is there anything built-in in latest releases of EcmaScript that will allow this?
- Credit for [User:Meriton](https://software.codidact.com/users/53280) for developing the following code ([first published here](https://software.codidact.com/posts/286304/286317#answer-286317)):
- ```javascript
- function replaceIn(e) {
- if (e.nodeType == Node.TEXT_NODE) {
- e.nodeValue = e.nodeValue.replaceAll("a", "");
- } else {
- for (const child of e.childNodes) {
- replaceIn(child);
- }
- }
- }
- replaceIn(document.body);
- ```
- Is it possible to get essentially the same recursive behavior without a procedure which calls itself?
- Is there anything built-in in EcmaScript to cause this?
#2: Post edited
Recursion without a procedure ("function") in JavaScript
Credit for [User:Meriton](https://software.codidact.com/users/53280) for developing the following code ([first published here](https://software.codidact.com/posts/286304/286317#answer-286317)): ```javascript function replaceIn(e) { if (e.nodeType == Node.TEXT_NODE) { e.nodeValue = e.nodeValue.replaceAll("a", ""); } else { for (const child of e.childNodes) { replaceIn(child); } } } replaceIn(document.body); ``` Is it possible to get essentially the same recursive behavior without a procedure which calls itself? Is there anything built-in in latest releases of EcmaScript that will allow this?
#1: Initial revision
Recursion without a procedure ("function") in JavaScript
Credit for [User:Meriton](https://software.codidact.com/users/53280) for developing the following code ([first published here](https://software.codidact.com/posts/286304/286317#answer-286317)): ```javascript function replaceIn(e) { if (e.nodeType == Node.TEXT_NODE) { e.nodeValue = e.nodeValue.replaceAll("a", ""); } else { for (const child of e.childNodes) { replaceIn(child); } } } replaceIn(document.body); ``` Is it possible to get essentially the same recursive behavior without a procedure which calls itself? Is there anything built-in in latest releases of EcmaScript that will allow this?