Recursion
Recursion using JavaScript does not differ from recursion for other programming languages: it is important to make sure to have both base casesA case in a recursive function that does not use a recursive call. and recursive casesA case in a recursive function that uses a recursive call ..
The tree structure of web pages makes recursion a natural way of processing a page. That is, calling a function on a tree rooted at a particular node can be acccomplished by calling the same function on each of the trees rooted at the children of the node.
In this example we simulate the textContent
property by forming a string consisting of all the text content of a page. Don't worry about the extra spaces due to blank space forming text nodes.
Note:
Hints:
- undefined
1
2
window.onload = startFunction;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
<!DOCTYPE html>
<html lang="en">
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX