|
What are your general debugging methods for coding JavaScript? I generally now only have to debug for larger scripts. Anyway if I write a script and see it is not working I first check the JS console in FF, which I think is personally a great debugger. Next if the code still isn't working, I use alert on some of my variables to discover their values and look for possible screw ups. I also alert with conditionals something like: if(blah.innerHTML.match(/whatever/)){ alert('Yes!'); } And if I don't get an alert I know there is probably something wrong with the regular expression and if not that I screwed up the conditional or somewhere around there. What methods do you use?
|
Greg says: Coding music... Greg says: Hmm... Greg says: I wouldn't rule it out. Chris 3.0 [New features? Yes.] says:
Greg says: If you think about machine code it's a bunch of 1s and 0s Chris 3.0 [New features? Yes.] says: Anything is possible. Greg says: Yeah try to code Metallica Chris 3.0 [New features? Yes.] says: Yeah, I'll get right on that... right after I learn to fly.
|
|
|
|
I use the RegExp tester for FireFox to make sure any RegExp string I write will actually work. I'm not that good at RegExp .
|
wat
|
|
|
|
JS console in FF. If its an error in IE, I've learned how to deal with those, as they're usually "Runtime Errors" which come from using certain methods of innerHTML on a DOM created object.
As you said, next step is the RegExp method of alert. I had a problem with that yesterday actually and couldn't figure it out. Came down to the fact that .+? doesn't match line breaks.... =/
|
|
|
|
|
- Bugzilla for Mozilla Firefox - Alerting variables to see if they have been set etc.
|
|
|
|
I just remembered another one.... Cali taught me this. Since IE and FF handle the source differently, you can view what's be interpreted line for line with typing this in your URL window and hitting enter. javascript:"<xmp>"+document.body.innerHTML+"</xmp>"; But if you have FF, get the "Web Developer Toolbar"... View Source menu has an option to "View Generated Source"
|
|
|
|
|
Cali had many cool things to show off. i learn a few things form him jsut by reading his posts.
|
k
|
|
|
|
Debugger codes help, and alerts.
also, on a side note, .+? isn't grabbign commas. Grar.
|
|
|
|
|
Debugger codes help, and alerts. also, on a side note, .+? isn't grabbign commas. Grar. yes it does.
|
|
|
|
Didn't for me. Found a way to work around it though. Neways. Firebug. =D
|
|
|
|
|
Didn't for me. Found a way to work around it though. Neways. Firebug. =D Using a "," works : if(td[2].innerHTML.match(/hey,/i)){
|
|
|
|
javascript:alert(/.+?/.test(",,,,"));void(0);
It does work. =/
|
|
|
|
|
Something I just found out: function omg(){ alert('omg'); }
javascript: alert(omg); Would alert function omg(){ alert('omg'); }
|
|
|
|
Well yeah, because you're alerting the value of the variable "omg", which is actually that function. var omg = function(){ alert("omg"); } That's basically how its interpreted (correct me if I'm wrong.)
|
|
|
|
|
Didn't for me. Found a way to work around it though. Neways. Firebug. =D Using a "," works : if(td[2].innerHTML.match(/hey,/i)){Not when your working with checking wether there is a comma or not.
|
|
|
|
|
Stream through the code lots of times
|
|
|
|