From 649b353ebc23b09d840faf927a2eeca41ee164bf Mon Sep 17 00:00:00 2001 From: Larry Clapp Date: Thu, 25 Oct 2018 21:27:54 -0400 Subject: [PATCH] More updates after code review - Update Truthy documentation - Streamline TypeNumber case of Truthy --- src/syscall/js/js.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/syscall/js/js.go b/src/syscall/js/js.go index e095eaa12be..12ea5e743db 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: