Re: Time is not a function
By: Digital Man to Kirkman on Sun Jan 04 2015 07:12 pm
>> I have noticed that when I'm working on JS projects for the board, if
>> I do something dumb that crashes the script, sometimes it affects
>> other javascript components on the board.
>> For example, say I'm writing a game, and I leave out a curly brace or
>> something. The BBS will throw an error. I'll fix my code, but then
>> later when I go to post a message, SlyEdit crashes on launch with the
>> error "time is not a function."
DM> time() is a global function (a.k.a. method) in the Synchronet object
DM> model, so it is possible that if your script executes in the same context
DM> and somehow deletes or overwrites the time() function that could trigger
DM> the error, but I don't think that would be normal.
FWIW, I ran into this again today and tracked it down. I have a series of
helper functions that I call from my doors. One of these modifies the
Date.prototype to add a method. Inside that, I declared a "time" variable
without using "var." This must be where it was colliding with the global
function.
For now I've renamed the variable to "t" and added "var" so it's local. But
I'll probably redo all that stuff eventually since it's a bad idea to modify
prototypes like that.
--Josh
////--------------------------------------------------
BiC -=- http://breakintochat.com -=- bbs wiki and blog
---
■ Synchronet
|