Internet Explorer 11 - Declare Javascript variables in developer tools console

2.4k views Asked by At

How can I create debug variables in IE11 developer tools console like in Chrome, for example?

I have tried

1) a = new String("latex");
2) var a = new String("latex");

For the first one I got a Variable undefined in strict mode
For the second one I got undefined and whenever I try to access variable "a" I get the error 'a' is undefined

4

There are 4 answers

0
bitweiß On

Did you try to access the variable in the same frame context it has been defined in? In the Console tab/area ... there is a dropdown field in the upper right corner (right to the log level filter and the clear log button). Variables/Objects only live in the frame context they have been created in. Also, when you created the debug variable while a debugger breakpoint was active, you created that variable in the current scope.

1
A. Abramov On

I am not sure what kind of javascript you're into with this new String("...") syntax, but for what I know the modern javascript in most browsers can recieve string values into var type parameters, as well as many other basic types - i.e

var a = "latex"

EDIT:

Apperently there is something such as new String - my bad :) As mentioned in the comments, you can access it via <parameter name>.toString() if you want to be able to access the properties; Just learnt that myself today. :)

More about js strings you can find here.

0
Quovadisqc On
0
Daniel On

I ran into something similar where I couldn't even declare variables but it was because I was paused on a breakpoint. Go figure.