Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

syscall/js: allow deletion of an object property #35227

Closed
advdv opened this issue Oct 29, 2019 · 2 comments
Closed

syscall/js: allow deletion of an object property #35227

advdv opened this issue Oct 29, 2019 · 2 comments

Comments

@advdv
Copy link

advdv commented Oct 29, 2019

What version of Go are you using (go version)?

go version go1.13.3 darwin/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/adam/Library/Caches/go-build"
GOENV="/Users/adam/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/adam/Projects/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/adam/Projects/go/src/github.com/advanderveer/9d587b277/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/8g/sd7s1zr94f948ds6_q0v3q180000gn/T/go-build209901922=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

I want to delete an js object property

What did you expect to see?

js.Global().Del("foo")

What did you see instead?

As far as i can tell there is no way to delete a property from a JS object, i tried setting it to nil or undefined but the key is still present:

js.Global().Set("__c", "foo")
js.Global().Set("__c", nil)
js.Global().Set("__c", js.Undefined())
println(js.Global().Call("hasOwnProperty", "__c").Bool()) //will be true
@tmthrgd
Copy link
Contributor

tmthrgd commented Oct 29, 2019

This is a duplicate of #33079 and is included at tip (go1.14): https://tip.golang.org/pkg/syscall/js/#Value.Delete.

@agnivade
Copy link
Contributor

Thanks @tmthrgd. Closing since it's already fixed.

@golang golang locked and limited conversation to collaborators Oct 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants