[turboid] javascript solutions

Home     Contact     Search     About me
Other
08 Feb 2012

Analysing JavaScript functions

Get detailed informations about your functions

Standard JavaScript does not provide a that powerful Function object. There are three properties (arguments, arity, caller) and no function for dealing with functions. This now is supplied by Turboid.

Below you find a function reference for the JavaScript Function object after including Turboid into your website. In order to use these extra functions, simply download the free Turboid framework and put it into the directory of your HTML file, then write this line into the head section of your HTML file, and that's it:

	

Alternatively, you can use the smaller Turboid core if you don't want to download the whole framework.

	

Now let's go ahead:

[Function].getHead()

Returns a string value containing the head of the function. If applied for example on function myFnc(a, b){ x=0; } it would return function myFnc(a, b)

[Function].getBody()

Returns a string value containing the body of the function. If applied for example on function myFnc(a, b){ x=0; } it would return x=0;

[Function].getName()

Returns a string value containing the function name. If applied for example on function myFnc(a, b){ x=0; } it would return myFnc.

[Function].getParameters()

Returns a string value containing the parameters. If applied for example on function myFnc(a, b){ x=0; } it would return a, b.

[Function].clone()

Returns a function which is independent from the first one and represents a copy of it. Usage example secondFnc = myFnc.clone();

[Function].get(varName)

Returns parameter values passed to the surrounding function by way of properties. Example usage:

	function exampleFnc(){
		alert(exampleFnc.get("costs"));
	}
	exampleFnc.costs = 1000;
	exampleFnc();

in order to achieve the passing effect, the function must be called immediately after defining the property. As with the standard way of passing values, the parameter is then not "visible" outside the function (respectively after calling the function), because the .get()-function deletes the property.

[Function].isEmpty()

Returns a boolean value whether the function contains code or not (comments are not considered).

thisFunctionName()

Returns a string value containing the name of the surrounding function.


Comments

Add comment:

Name: (required)
E-Mail: (required, remains invisible)
Website:
Comment:
Please check all (anti-spam):