dennwc/dom

Confusion regarding the Get & Set functions for js.go

Closed this issue · 2 comments

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))
}

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.