function observer(target) {
if (typeof target !== 'object' || target === 'null') return target
if (Array.isArray(target)) {
target.__ptoto__ = a
}
for (key in target) {
defineReactive(target, key, target[key])
}
}
const arr = Array.prototype
const a = Object.create(arr)
['push', 'pop', 'unshift', 'shift'].forEach(methodName => {
a[methodName] = function() {
updateView()
arr[methodName].call(this, ...arguments)
}
})
function defineReactive(target, key, value) {
observer(value)
Object.defineProperty(target, key, {
get: function() {
return value
},
set: function(newVal) {
if (newValue !== value) {
value = newValue
updateView()
}
}
})
}
function updateView() {
}
console