1

I am writing JavaScript functions for a web app and I want to test them with different values. How can I test JavaScript functions outside of my web application?

I have Visual Studio 2010 and created a new JavaScript file with the function, how can I debug just that file?

Any help is much appreciated

asked Mar 25, 2014 at 16:11

2 Answers 2

2

in chrome, hit F12 to open the developer tools. Then navigate to the "Console" tab. you can paste the contents of your javascript file at the prompt and press enter to run it.

note: shift+enter is newline. enter executes your code.

i pasted this in for example:

function test(arg) {
 return 'hello ' + arg;
}
test('world');

enter image description here

then pressed enter:

enter image description here

If you want to use Internet Explorer, open up a new tab and go to any page (google, anything as long as it's not blank). Then hit F12 to access the developer tools. From there go to the "Script" tab. Under the script tab, on the top-right press the "Console" button. At the bottom of the console panel you can paste in your script and press "Run script" to execute it.

enter image description here

answered Mar 25, 2014 at 16:18
Sign up to request clarification or add additional context in comments.

4 Comments

Nothing of this sort in IE?
@user793468- I added instructions for Internet Explorer to my answer
I wonder why VS2010 does not have any quick way to debug/test javascript functions like browsers do
Is there something like this for python?
0

depends on what browser you are using.

To debug javascript you have to run your application in the browser. In Chrome, Firefox and the latest Internet explorer you can press F12 to open a javascript debugging console. You can execute javascript functions, place breakpoints and much more

answered Mar 25, 2014 at 16:17

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.