471,354 Members | 1,500 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,354 software developers and data experts.

javascript 'function not defined' error in recursion

hi, i have a problem which recursion fits perfectly, however; after working with the base function (which has no errors and works correctly) the recursions return a "function not defined" error in ff's js console. i tried a few things that came to mind but nothing has changed it... i found some interesting articles on the net regarding javascript's callbacks, and found out that due to callbacks recursion may end up eating a lot more memory than normal recursion does, which makes it sound like js and recursion don't go together.

the second time i call value1(), when it is in the first loop of the recursive function, i get the 'function not defined' error. i also get a not defined error regarding the chars string on that same line if you get past the function error. i'm guessing its related...

any help is appreciated.

<script type="text/javascript">
var chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVW XYZ";

function value1(baseChar, base, options) {
this.baseChar = baseChar;
this.base = base;

if(options == "")
this.valid = new Array(0);
else {
this.valid = new Array(0);

for(var i=0; i<options.length; i++)

this.child = new Array(0);

function mod() {
var aNum = 0;
var input = "\"eHgMYUn_MWW[SLZ!kKOiM\\SX[Uif'GcaO]YU`eWPJIv|g`YTVTlrUPQT`R_T MgIO~pcM[QHaQVrYI^u'f,ueHgMYU,";

var v1opt = new value1("", 0, chars);


function recurse1(v1opt) {
document.write("base char: "+ v1opt.baseChar +"<br />");
document.write("base: "+ v1opt.base +"<br />");
document.write("valid: "+ v1opt.valid.join() +"<br />");

for(var i=0; i<v1opt.valid.length; i++) {
if((v1opt.base + v1opt.valid[i].charCodeAt(0)) <= 1286) {
document.write("child: "+ v1opt.valid[i].charAt(0) +"<br /><blockquote>");
var a = new value1("", 0, chars);
child = v1opt.child.push(a);

for(var j=0; j<chars.length; j++)
if((child.base + chars.charCodeAt(j)) <= 1286)

if(v1opt.child.length != 0)
for(var i=0; i<v1opt.child.length; i++)

Jun 21 '06 #1
1 17142
May be th problem is in v1opt.child(i), as if the recursion is working correctly with scalar types. Have U tried to call the recurse1 for any scalar type?
You can assign this object to any variable and try to call for this one.
Jun 22 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

19 posts views Thread by Fabian | last post: by
6 posts views Thread by den 2005 | last post: by
1 post views Thread by pbmods | last post: by
2 posts views Thread by lielar | last post: by
30 posts views Thread by Jeff Bigham | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.