probably a silly question, but somehow i ended up on the debug function available in Google Chrome Console, which if i try to print it on the console i get:
ƒ debug(function, condition) { [Command Line API] }
however i'm totally unable to console.log something from it in any way, and I can't find any documentation online...
I've tested it on Firefox and i get Uncaught ReferenceError: debug is not defined so it's not cross platform, but maybe for development purpose it might be helpful
Maybe is related to debugger;?...
This is documented in the Console Utilities API Reference:
debug(function)
When the specified function is called, the debugger is
invoked and breaks inside the function on the Sources panel allowing
to step through the code and debug it.
debug(getData);
Use undebug(fn) to stop breaking on the function, or use the UI to
disable all breakpoints.
For more information on breakpoints, see Pause Your Code With
Breakpoints.
Related
Until recently I've used console.log extensively in Electron, both from code and monitoring results in the Developer Tools console, and also by typing console.log("something or other") directly in the Developer Tools console.
All of a sudden it's no longer working. Nothing happens when running console.log() from a JS script, and if I type console.log("test") in the Developer Tools console the response is "undefined". console.log by itself (no parentheses) shows ƒ (){} as opposed to function log() {[native code]}, which perhaps explains the lack of functionality?
Trying to figure out how that might have happened and how to resolve it -- did I accidentally click on some preference or setting somewhere? Quite the PITA to lose that.
where console.log() stopped working
console.context().log() is the alternative command that so far has been working.
I'm running tests with jasmine/karma and although all tests run ok, process exits with 1. I suspect that these are Firefox's web console error messages, which are produced when I try to add existing record into IndexedDB object store. Is there any option to disable these messages or ignore them in Karma runner?
UPD: These errors occur in web console even if I wrap my code inside try..catch, so it's browsers default behaviour.
https://travis-ci.org/1999/sklad/builds/36609101
Just in case someone needs this. The answer is here. In brief, Firefox shows that this is a usual DOM error and it has default behavior. So if you prevent default 'onerror' behavior which is 'abort', everything goes fine. You can see the result here.
My Javascript code (hundreds of lines) hangs Chrome and when I debug the issue I find out that a variable was undefined. I don't get errors in the console. So this is making my debugging more time consuming because there are no errors or exceptions or anything that tells me where the issue is.
I don't want to add debugging code. Is there a way to make the debugger put out an error, break in the debugger or give an exception or show anything useful for the developer when hitting an undefined variable during runtime? It doesn't have to be for Chrome only.
You can break into the DevTools debugger when a JavaScript error occurs using the Pause on JavaScript Exceptions feature. It has two active modes; pause on all exceptions, and pause on uncaught exceptions.
Based on the description of your experience, the application you are working on may have errors that are caught but not re-thrown or logged. Using the "Pause on All Exceptions" (blue colored pause icon), will help in this scenario.
Note: some libraries, like jQuery, catch exceptions and do not re-throw them. If you have this experience, you may need to advance past these exceptions or set the "Pause on All Exceptions" feature after all dependencies have loaded.
window.onerror = function() { debugger; }
I see every time error in my visual studio even code working fine for me in every browser.
the problem is that i not want to watch the error window every time
"Microsoft JScript runtime error: Object doesn't support this property or method"
how i can stop visual studio to showing errors relate to my javascript code.
From your comment:
my function try to call
three or four function some of them
not implemented in all browser. this
is not error but they give me error.
well how i can stop this if i want to
Usually you test first whether the function is implemented - for example, if you'd like to use getElementsByClassName:
if (document.getElementsByClassName){
var nodes = document.getElementsByClassName('myclass');
...
}
The condition in the first line returns only true if the function actually exists.
EDIT:
As to Visual Studio 2010, it seems that activating debugging for silverlight turns off debugging for javascript, see http://vishaljoshi.blogspot.com/2009/06/disabling-script-debugging-with-vs-2010.html
I usually use Firefox instead of IE and therefore never had that particular problem.
How to Debug java Script Error Using Firebug?
Duplicate
How can I set breakpoints in an external JS script in Firebug
Debug using FireBug.
Just check the line on which the error is occuring, then, just before that line, write a "debugger" call.
debugger; //Will invoke FireBug's debugger.
var err = abcs; //Line containing error
To debug an error in firebug :
1- select inspect tab from menu
2- Set break point in the line that
causes error
3- Refrsh the page
4- use F10 to step by step debug and
F5 to end debgging
It's like debgging of visual studio
Use the console.log(yourObject) function to output anything to the firebug console. It is just like running a var_dump and you can view all your objects and their contents. This is very helpful if you want to check on the contents of a particular variable or even a particular DOM object.
Instead of using cheap alerts - the console.log() function is cleaner and you can see all the outputs neatly in your console pane.
Note however you need to remove all references to the console.log function when you deploy your website as it would not run in IE.
you can put breakpoints in the code, and wait for the execution to hit them. Then you can walk in the code, and use watches to know the values of variables.
You can use Firebug, and for debugging in chrome, you can use firebug lite
Why Firebug , try Visual studio , it has a rich debugging features ;)