undefined
as an Identifier JS-012726 : 'text-neutral-600 hover:text-neutral-900 dark:text-neutral-600 dark:hover:text-neutral-100',
27 'rounded-md px-6 font-sans text-lg font-light duration-300'
28 )}
29 aria-current={tab.href ? 'page' : undefined}30 >
31 {tab.name}
32 </NavLink>
23 const [connected, setConnected] = React.useState(false);
24 const { loggedInUser, streamToken } = useAuth();
25 const profileData = useProfile(
26 loggedInUser.username !== undefined ? loggedInUser.username : ''27 ) as Profile;
28
29 if (loggedInUser && streamToken && !connected) {
42 }
43 await updateUser(token, firstName, lastName, username)?.then(() => {
44 del('loggedInUser');
45 if (username === undefined) { 46 username = loggedInUser.username;
47 }
48 setSubmitting(false);
38 const { firstName, lastName } = values;
39 let { username } = values;
40 if (username === loggedInUser.username) {
41 username = undefined; 42 }
43 await updateUser(token, firstName, lastName, username)?.then(() => {
44 del('loggedInUser');
The undefined
variable in JavaScript is actually a property of the global object. As such, in ECMAScript 3 it was possible to overwrite the value of undefined
. While ECMAScript 5 disallows overwriting undefined
, it's still possible to shadow undefined, such as:
function doSomething(data) {
var undefined = "hi";
// doesn't do what you think it does
if (data === undefined) {
// ...
}
}
Because undefined
can be overwritten or shadowed, reading undefined
can give an unexpected value. (This is not the case for null
, which is a keyword that always produces the same value.) To guard against this, you can avoid all uses of undefined
.
This ensures that undefined will always hold its original, expected value.
var foo = undefined;
var undefined = "foo";
if (foo === undefined) {
// ...
}
function foo(undefined) {
// ...
}
var foo = void 0;
var Undefined = "foo";
if (typeof foo === "undefined") {
// ...
}
global.undefined = "foo";