Skip to main content

Difference between console.log and return?

Entry NodeJS
Quick Answer console.log outputs something to stdout รขโ‚ฌโ€ it's a side effect for visibility/debugging. return ends the function and passes a value back to the caller. They serve completely different purposes: console.log is for printing; return is for passing data. A function can console.log and return at the same time.

Answer

console.log prints output to the console; return sends a value back from a function to its caller.
S
SugharaIQ Editorial Team Verified Answer

This answer has been peer-reviewed by industry experts holding senior engineering roles to ensure technical accuracy and relevance for modern interview standards.

Want to bookmark, take notes, or join discussions?

Sign in to access all features and personalize your learning experience.

Sign In Create Account

Source: SugharaIQ

Ready to level up? Start Practice