Files
front-end-example/03-javascript-core/14-memory-and-execution/starter.js
2026-03-23 14:56:04 +08:00

38 lines
722 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

let scoreA = 80;
let scoreB = scoreA;
const userA = {
name: "小周",
city: "上海",
};
const userB = userA;
function printStepOne() {
console.log("步骤一");
}
function printStepTwo() {
console.log("步骤二");
}
function updateUser(user) {
// 任务:
// 1. 修改 user.city
user.city = '北京'
}
scoreB = 90
console.log('scoreA' + scoreA + ',scoreB' + scoreB);
userB.city = '秦皇岛'
console.log(userA.city, userB.city);
printStepOne()
printStepTwo()
updateUser(userA)
console.log(userA);
// 任务:
// 2. 修改 scoreB观察 scoreA 是否变化
// 3. 修改 userB.city观察 userA.city 是否变化
// 4. 按顺序调用 printStepOne 和 printStepTwo
// 5. 调用 updateUser(userA)