Undefined in Browser Console.
Unlike this cover pic , mai sab btaunga , Hausla rakho.. Blog padho (-.-)

What is undefined in javascript? 🤯
There are 7 primitive data types in javascript, Undefined is one of them.
In JS if there is a variable that is declared but is not assigned any value to it then it is assigned a value of undefined. and Once a value is assigned to the variable it removes the undefined.
In non-technical terms, When you are traveling to a local train, and you put a handkerchief on a place to reserve a seat for your friend, that place until unoccupied will be the same as undefined, but when your friend sits in that place it gets changed from undefined to assigned (same as variable assigning some value 😉 )
var aVariable;
console.log(aVariable); // mai huu undefined
aVariable=20;
console.log(aVariable); // mai 20 hu
what is undefined in functions?
Functions are the heart of javascript 💖. One of the key property of functions is it always returns something. In non-technical terms, they are the most generous person who always gives something back.
But what if you don't define what to return?🧐 the function be like mai kya karu fir job chor du? No it won't ,leave its job - it will simply return undefined.
function selmonBhoi😎 (){
//nothing to return
}
selmonBhoi()//undefined
//========================
function selmonBhoi(){
return "deer" 🦌
}
selmonBhoi() //deer (😡 tu footpath pe mil 🛣️)

Now selmon bhai to me be like (👆) 😞
Why does the browser return undefined every time we console anything? 🤔
The answer is pretty simple. This is due to the nature of REPLs, which are command-line tools that scripting languages use. (❁´◡`❁)

Chalo bhai dekho ab mai kya btata hu ༼ つ ◕_◕ ༽つ
What is a REPL?
You may be wondering what REPL is ?
REPL stands for Read, Evaluate, Print, Loop. REPLs are a coding environment tool that is a common feature among scripting languages. Whether you access it with ‘irb’ for Ruby, ‘node’ for JavaScript or ‘python’ for Python 🐍, entering into a REPL creates a sandbox environment for you to explore your code.
Read - First, they read whatever code you have entered in your current terminal expression using the language native to your version of the REPL. If you are using a Node.js REPL then your REPL will read the code as JavaScript.
Evaluate - This could include any arithmetic, loop structures, string, array or object manipulation or any other possible operations.
Print - print whatever the REPL was informed to print.
Loop - this doesn’t relate to a for or while loop. What we mean by the loop is that once all of your statements or code have been read and evaluated and any information printed, we loop back to a state in which the computer is ready for more input. Thus after every bit of code you enter in the REPL is read, evaluated and printed, the computer prepares itself to run more operations.
//The eval() function evaluates JavaScript code represented as a string and returns its completion value.
//E in REPL does this..
var a = 1;
//undefined
var valOfAVarStatement = eval('var x = 16;');
// valOfAVarStatement === undefined
var valOfAnAssignment = eval('x = 16;');
// valOfAnAssignment === 16
console.log("life is undefined")
//life is undefined
//undefined
When we are calling console.log() from our browser console or the terminal, we are calling it from a JavaScript REPL.
With our new understanding of what REPLs are and how they work we can work through the process of console.log(“life is undefined”). First, the REPL will read in our command as JavaScript. Then it will look to evaluate parts of our command. The evaluating step will always return something, like the sum of 2 + 2 or a modified array, but in this case, there is nothing to evaluate. Therefore it returns undefined. The same goes for the first and second examples.
CONCLUSION
undefinedis assigned to a variable by javascript when we don't assign any value to it after it's declaration.functionsalways return something and they returnundefinedwhen we don't define what to return.Browser Console is also a REPL. It stands for Read, Evaluate, Print, Loop.
Evaluate step always returns something like
3 + 3= 6but in the case ofconsole.log("life is undefined"), there is nothing to evaluate.

