dennwc / dom

DOM library for Go and WASM
Apache License 2.0
490 stars 59 forks source link

Confusion regarding the Get & Set functions for js.go #11

Closed jarkyll closed 5 years ago

jarkyll commented 6 years ago

Hi! I saw Value{global} being used and global being used for the get & set function. Are they interchangeable?

// Get is a shorthand for Global().Get().
func Get(name string, path ...string) Value {
    return Value{global}.Get(name, path...)
}

// Set is a shorthand for Global().Set().
func Set(name string, v interface{}) {
    global.Set(name, toJS(v))
}
jarkyll commented 6 years ago

https://github.com/dennwc/dom/blob/master/js/js.go - for reference

dennwc commented 6 years ago

Yes, they are interchangeable as long as toJS is called for an argument.

In any case, I think your concern is valid, and I will make the code symmetrical for clarity.