github.com/goplusjs/gopherjs@v1.2.6-0.20211206034512-f187917453b8/compiler/natives/src/syscall/js/go114_js.go (about) 1 // +build js 2 // +build go1.14 3 4 package js 5 6 import ( 7 "github.com/gopherjs/gopherjs/js" 8 ) 9 10 func (v Value) IsNull() bool { 11 return v.Type() == TypeNull 12 } 13 14 func (v Value) IsUndefined() bool { 15 return !v.inited 16 } 17 18 func (v Value) IsNaN() bool { 19 return js.Global.Call("isNaN", v.internal()).Bool() 20 } 21 22 func (v Value) Equal(w Value) bool { 23 //return v.internal() == w.internal() && !v.IsNaN() 24 if v.Type() != w.Type() { 25 return false 26 } 27 switch v.Type() { 28 case TypeString: 29 return v.internal().String() == w.internal().String() 30 case TypeUndefined: 31 return true 32 case TypeNull: 33 return true 34 case TypeBoolean: 35 return v.internal().Bool() == w.internal().Bool() 36 case TypeNumber: 37 return v.internal().Float() == w.internal().Float() 38 case TypeSymbol: 39 return v.internal() == w.internal() 40 case TypeObject: 41 return v.internal() == w.internal() 42 case TypeFunction: 43 return v.internal() == w.internal() 44 default: 45 panic("bad type") 46 } 47 } 48 49 func (v Value) Delete(p string) { 50 if vType := v.Type(); vType != TypeObject { 51 panic(&ValueError{"Value.Delete", vType}) 52 } 53 v.internal().Delete(p) 54 }