Proposal Details
In JS I can do this:
function hello(options) {
if ("name" in options) {
if (options.name === undefined) { // could be "== null" to handle null & undefined
console.log(`You've opted to not provide your name`)
} else if (typeof options.name === "string") {
console.log(`Hello ${options.name}!`)
} else {
throw new TypeError("name is not a string")
}
} else {
console.log(`Name field is empty. Would you like to set it now?`)
// blah blah
}
}
This example illustrates the potential difference in semantics between a property being not present on an object and being undefined on an object.
You cannot currently detect the presence or absence of a property using syscall/js without resorting to calling Reflect.has(object, propertyName) via js.Global().Get("Reflect")...
I propose adding a Value.Has or similar method to expose the JS in operator similar to how instanceof is exposed.
Proposal Details
In JS I can do this:
This example illustrates the potential difference in semantics between a property being not present on an object and being undefined on an object.
You cannot currently detect the presence or absence of a property using syscall/js without resorting to calling
Reflect.has(object, propertyName)viajs.Global().Get("Reflect")...I propose adding a Value.Has or similar method to expose the JS
inoperator similar to howinstanceofis exposed.