feat: Add JavaScript core exercises and solutions

- Implemented exercises for array high-order methods, memory and execution, switch statements, and final review.
- Added starter and answer files for each exercise to facilitate learning.
- Created a runner HTML file to execute JavaScript code and display console outputs.
- Updated README files to include exercise objectives, tasks, and usage instructions.
This commit is contained in:
charlie
2026-03-13 11:09:19 +08:00
parent 4495ae0e28
commit 877acb5a8f
51 changed files with 1949 additions and 5 deletions

View File

@@ -0,0 +1,26 @@
const student = {
name: "林晨",
stage: "JavaScript 核心",
sayHello() {
const currentName = this && this.name ? this.name : "未知调用者";
const currentStage = this && this.stage ? this.stage : "未知阶段";
console.log(`你好,我是 ${currentName},正在学习 ${currentStage}`);
},
createArrowReporter() {
return () => {
console.log(`箭头函数继承到的 this.name${this.name}`);
};
},
};
student.sayHello();
const detachedHello = student.sayHello;
detachedHello();
const arrowReporter = student.createArrowReporter();
arrowReporter();
console.log("对象方法里的 this 通常指向调用它的对象。");
console.log("脱离对象单独调用后,普通函数里的 this 会跟着调用方式变化。");
console.log("箭头函数没有自己的 this它会继承创建它时外层的 this。");