question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Recommended approach for globally setting undefined

See original GitHub issue

First 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:open
  • Created 6 years ago
  • Reactions:1
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

19reactions
aarongodincommented, Mar 5, 2018

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.

5reactions
jackjocrosscommented, Mar 5, 2018

@maniator I was thinking the same, maybe a webpack plugin or babel transform that defines undefined as a function in each module.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found