purpose of console.log

Post a reply

Confirmation code
Enter the code exactly as it appears. All letters are case insensitive.
:D :) ;) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :!: :?: :idea: :arrow: :| :mrgreen: :geek: :ugeek:

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review

Expand view Topic review: purpose of console.log

purpose of console log

by BeJimmieSiz » Mon Sep 02, 2019 11:26 am

Somewhere in your code you are looking up child windows via an ID, and the child windows do not exist. If you did not add such code, then it could be that you used code from somewhere else that used this technique



Re: purpose of console.log

by JeremyMoritz » Fri Jun 15, 2018 12:13 pm

Remember that console.log() is a function. Therefore, you could put logic inside it. If you put a comment

Code: Select all

// 6 + 5
You'll only see that. But if you use a function

Code: Select all

It will log the result to the console.

The iDoNot() function you created here doesn't expect any arguments, so passing in the console.log (as you did in your last example) is just the same as calling it without passing anything into it.

If you don't fully understand this yet, just hang in there. The issue is only because these examples have been overly simplified. It will all make since in time, and you'll see the significant distinctions among comments, return statements of custom functions, and the console.log() function.

purpose of console.log

by matermultorum » Thu Jun 14, 2018 12:16 pm

I'm having trouble understanding the usefulness of console.log. The text mentions displaying typed out info and I can see that it functions differently than comments, but what does it do that comments don't? Maybe I don't understand what logging a message into the console means. Does it have benefits at a higher level that aren't as obvious at the level we are at? I also noticed that I get similar results no matter where I put the console.log statement in the following lines. When I invoke the function it says 678, when I switch console and the function I get 678 undefined (see below)

function iDoNot(){
return 678

Thanks in advance for looking at this!