Recommended approach for globally setting undefined
See original GitHub issueFirst off, thank you for this helpful package!
Using Babel, undefined
is scoped to the module that I import it in, but I want undefined
to be a function for my entire site. My current approach is:
import { undefined as undef } from 'undefined-is-a-function';
undefined = undef;
If this is a common use case would you consider adding a utility method?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Why a variable defined global is undefined? - Stack Overflow
The reason the first alert is undefined is because you re-declared global as a local variable below it ...
Read more >undefined - JavaScript - MDN Web Docs - Mozilla
The global undefined property represents the primitive value undefined. It is one of JavaScript's primitive types.
Read more >Detecting Undefined Variables - lua-users wiki
These approaches differ in terms of when and how access to undefined global variables are detected. First, let's consider the nature of the ......
Read more >`undefined` vs. `null` revisited - 2ality
undefined is “used when a variable has not been assigned a value” (source). null “represents the intentional absence of any object value” ( ......
Read more >JavaScript Best Practices - W3Schools
Global variables and functions can be overwritten by other scripts. ... with a missing argument, the value of the missing argument is set...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Following the single-responsibility principle, we should probably create a new package on npm called
undefined-is-always-a-function
. This package already has enough code in it. We wouldn’t want our complexity to go up too much.@maniator I was thinking the same, maybe a webpack plugin or babel transform that defines
undefined
as a function in each module.