TypeError: 无法为“y”上的“x”属性赋值:不是对象
信息
TypeError: Cannot create property 'x' on number '1' (V8-based) TypeError: can't assign to property "x" on 1: not an object (Firefox) TypeError: Attempted to assign to readonly property. (Safari)
错误类型
哪里出错了?
示例
无效情况
js
"use strict";
const foo = "my string";
// The following line does nothing if not in strict mode.
foo.bar = {}; // TypeError: can't assign to property "bar" on "my string": not an object