0

I am trying to debug a chrome extension. I have opened up the background page in the extension page but I was wondering if there was a way to look at the array type that I have.

For example, I have the code

function main() {
var cells = document.getElementsByClassName('sectionFieldInstructor');
var length = cells.length;
var professors = [];
var profCount = 0;

Where my cells is the teachers in the list. I would like to view which teachers I have in the cells array.

Also, in the inspected page, the teachers name is listed as

<a href="search?mode=search&instructor=TEACHER">A. TEACHER</a><br/>

Would it be affected by that?

Thanks!

1
  • Just set a breakpoint inside the function and hover the mouse on the variable. The debugger is extremely powerful with lots of features that really speed up and help development, read some tutorial like the official one: developers.google.com/web/tools/chrome-devtools/debug/… Commented Sep 7, 2016 at 19:32

1 Answer 1

1

You can do that with Chrome developer tools. The easiset way is to add

var cells = document.getElementsByClassName('sectionFieldInstructor');    
    console.log(cells); //Add this line     
var length = cells.length;

Then it will be displayed in your console. (There is a tab in dev tools called console.)

You can call that function from the console as well by typing:

main();

Hope this helps

Sign up to request clarification or add additional context in comments.

1 Comment

I couldnt get the console to open up in dev tools for some reason but I found it when inspecting the page. Thanks!

Your Answer

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.