diff --git a/src/syscall/js/js.go b/src/syscall/js/js.go index e095eaa12b..12ea5e743d 100644 --- a/src/syscall/js/js.go +++ b/src/syscall/js/js.go @@ -361,9 +361,9 @@ func (v Value) Bool() bool { } } -// Truthy returns the JavaScript "truthiness" of the value v. In JavaScript, +// Truthy returns the JavaScript "truthiness" of the value v. In JavaScript, // false, 0, "", null, undefined, and NaN are "falsy", and everything else is -// "truthy". See https://developer.mozilla.org/en-US/docs/Glossary/Truthy. +// "truthy". See https://developer.mozilla.org/en-US/docs/Glossary/Truthy. func (v Value) Truthy() bool { switch v.Type() { case TypeUndefined, TypeNull: @@ -371,10 +371,7 @@ func (v Value) Truthy() bool { case TypeBoolean: return v.Bool() case TypeNumber: - if v.ref == valueNaN.ref { - return false - } - return v.ref != valueZero.ref + return v.ref != valueNaN.ref && v.ref != valueZero.ref case TypeString: return v.String() != "" case TypeSymbol, TypeFunction, TypeObject: