Skip to content
Akin C edited this page Mar 1, 2019 · 11 revisions

Welcome to the Javascript-recursion-with-arguments.callee- wiki!

This repository is part of a larger project!

◀️ PREVIOUS PROJECT| NEXT PROJECT ▶️


Javascript`s property arguments.callee is able to refer to the function in which it is called. This allows the developer to use it for recursive purposes, as the following example should show:

var myName  = "Incrementis";
var letters = [];

//Divides the string into letters and saves them into an array
function Divide(name, position, container)
{
	if(position === 0)
	{
		container.push(name[0]);
	}
	else
	{
		//Call of the function "Divide" within "Divide"
		arguments.callee(name, position-1, container);
		
		container.push(name[position]);
	}
}

//First Call
Divide(myName, myName.length-1, letters);

//Outputs: ["I", "n", "c", "r", "e", "m", "e", "n", "t", "i", "s"]
console.log(letters);

📕 It seems that it is recommended to avoid using arguments.callee. Explained reasons for this should be found here, within the item "Making eval and arguments simpler".

Content

The user interaction part could look like the content as seen below by starting "index.html" in a web browser and interacting with its features.

ERROR: No image found!

  • The input field expect a number value which should represent the length of the Fibonnacci sequence
  • 🅱️ utton "CALCULATE" starts calculating the sequence
  • After pressing "CALCULATE" the result should be shown

To use the project just download the files and execute "index.html". Note that all files(folder "wiki_images" excluded) should be placed in the same folder so that the functionality of the code is guaranteed.

Clone this wiki locally