“undefined” through example with a simple function
Simple example when a function parameter is recognized as “undefined” in JS.
Function
function undefinedOrNot(value) {
if (value === undefined) {
return 'error';
} else {
return value;
}
}
- Input undefined
undefinedOrNot(undefined)
// "error"
2. Input no parameter
undefinedOrNot()
// "error"
3. Input a string parameter
ensure("I am string")
// "I am string"
I am blogging what I’ve learned to find later here for myself. If you happened to read this shit and there is wrong information, it would be appreciated to add a comment below.