what is console.log?πŸ‘€

Β·

2 min read

console.log("what is console.log?")

Javascript is everywhere and people who are using it use this console.log regularly. so what is console.log and what is it returning? why are we using it?

console.log is a javascript function used for printing or logging the output in the browser console. let's take the example of jack who is a pro programmer in javascript. he always ended up getting lots of errors. so his senior suggest that he first tries to log output in the console, and after logging output in the console it is straightforward to debug the code and get to know which code produces errors.

functions are the heart ❀ of javascript. when we are working with functions always has some unique behavior. it takes some input and produces the output according to the procedure or the instruction given to it.

but what if I don't give it any input? πŸ™„ Obviously it doesn't return anything. but in javascript, it returns undefined πŸ€—.

undefined is a placeholder in javascript that holds some place for the declared but hasn't assigned a value yet so undefined is holding space for it?

why is the console log returning undefined every time try to log it into the console πŸ€”?

so when we try to log something or print something into the console it returns one desired output (yes!! after many attempts) and the other one is undefined.

here is the console.log which doesn't have any return value will return an undefined.

any function which does not have a return statement or does not have a value to return returns undefined.

summary ✨:

console.log is a type of function in javascript that doesn't have any return value so it returns undefined means no value.

will try to write in a more simplified and better way 🀠 thanks for readingπŸ₯°

Β