Packages

QuickJS JavaScript engine for Erlang (powered by quickjs-ng)

Current section

Files

Jump to
quickjs c_src quickjs-ng tests null_or_undefined.js
Raw

c_src/quickjs-ng/tests/null_or_undefined.js

import {assert} from "./assert.js"
let ex
try {
null.x
} catch (e) {
ex = e
}
assert(ex instanceof TypeError)
assert(ex.message, "cannot read property 'x' of null")
ex = undefined
try {
null["x"]
} catch (e) {
ex = e
}
assert(ex instanceof TypeError)
assert(ex.message, "cannot read property 'x' of null")
ex = undefined
try {
undefined.x
} catch (e) {
ex = e
}
assert(ex instanceof TypeError)
assert(ex.message, "cannot read property 'x' of undefined")
ex = undefined
try {
undefined["x"]
} catch (e) {
ex = e
}
assert(ex instanceof TypeError)
assert(ex.message, "cannot read property 'x' of undefined")
ex = undefined