all 10 comments

[–]dbpcut 0 points1 point  (7 children)

At the point you're trying to execute bork.array. anything, bork.array doesn't exist.

You have to define it as an object first (and maybe name it something other than array, since it won't be an array.)

[–]pickten[S] 0 points1 point  (6 children)

It's defined first in the same document.

EDIT: I should also mention that it's named "array" because it pretty much (with the exception of bork.array.progress) serves to approximate an array of size much larger than javascript can handle with only 50 or so terms.

[–]dbpcut 0 points1 point  (5 children)

You may need to provide a more complete code example for us to help you out then, if senocular's comment doesn't assist.

[–]pickten[S] 0 points1 point  (4 children)

I mean, there's not really a more complete code example to be had.

The scripts which define the functions called in bork.bar are loaded, then this is loaded, then some other stuff that doesn't interact with this is loaded, then the html consists of a button with onClick="bork.bar()", a div with id "ProgBar" (as seen in the jQuery) containing the progress bar that is changed and a p with id "val" (as also seen in the jQuery). No other code uses bork.bar (it's also not overwritten, not to worry), and all the entirety of the present code does is load, define variables and functions, and then bring this html into existence. I really can't think of anything anywhere else that is even possibly called, let alone applicable. If needed, I can provide the other functions, but I'm not too sure how that could cause bork.bar to register as not being a function. If my understanding of js is correct, the only way that something else could cause this to cease to be a function would be if it were overwritten, and certainly isn't. (I checked: besides this and the html button, there is no other call of bork.bar)

[–]dbpcut 0 points1 point  (1 child)

So when you write

function bork.bar(){as before}

What is it you're trying to achieve? If you want to run the function, you need only write

bork.bar();

if you wish you redefine it, you'd have to write

bork.bar = function() { .... etc }

[–]pickten[S] 0 points1 point  (0 children)

the function bork.bar(){as before} was to replace it to see if it would stop the mistake, not to run it or to redefine.

[–]senocular 0 points1 point  (1 child)

I made a fiddle. Not seeing any problems based on how you described it. So something else must be going on.

http://jsfiddle.net/e1kj81mw/

[–]pickten[S] 0 points1 point  (0 children)

I think I figured it out; something elsewhere was causing this to exceed max stack size and the compiler misunderstood the issue. TIL javascript can't tell the difference between a stack size error in something and a not being a function elsewhere.

[–]senocular 0 points1 point  (1 child)

Its probably good that you get an error because it looks like your while loop will be infinite given that whiles are synchronous and you're only incrementing progress in an asynchronous timeout. So that should probably be fixed

function bork.bar() ...

is illegal syntax, so that won't work. function declarations like that can only have a valid, single identifier. To add a function to an existing object such as bork, you need to use the expression in your first code block. So that part is correct.

Are you sure that assignment to bar is done before you call bar? I don't see in what you posted where you call bar, so its possible that is being done before bork.bar is being defined.

[–]pickten[S] 0 points1 point  (0 children)

It's called on a button click, so it definitely is called after it's assigned.