Skip to content
📜

JavaScript 基础

150 道练习

150 道 JavaScript 练习覆盖变量作用域、闭包、异步编程、数组方法与 ES6+ 语法,每题附运行结果预测与详细解析。

  1. 1

    Let 对比 Const 测验

    测试你的理解的 什么 happens 当你 reassign const 变量 in JavaScript.

    单选题 简单
  2. 2

    Predict 变量 Reassignment

    Predict 输出的 JavaScript program 那个 reassigns let 变量.

    预测输出 入门
  3. 3

    Declare JavaScript 常量

    练习 using const keyword 到 declare 常量变量 in JavaScript.

    填空题 入门
  4. 4

    JavaScript Primitive 类型

    检查你的理解的 哪个类型是 primitives in JavaScript.

    概念检查 中等
  5. 5

    查找 Arrow 函数错误

    Spot 常见语法错误 in JavaScript arrow 函数 declaration.

    找错误 简单
  6. 6

    Predict 函数 Call Result

    Predict 输出的 简单 JavaScript 函数 call 使用 numeric 实参.

    预测输出 入门
  7. 7

    JavaScript 数组长度测验

    测试你的理解的 长度属性 on JavaScript 数组.

    单选题 入门
  8. 8

    Predict 数组推送输出

    Predict 新长度的 JavaScript 数组之后 calling 推送.

    预测输出 入门
  9. 9

    JavaScript 对象键 测验

    测试你的理解的 如何对象键 工作 in JavaScript.

    单选题 入门
  10. 10

    Predict 对象属性 Access

    Predict 值 returned 通过 accessing 属性 on JavaScript 对象.

    预测输出 入门
  11. 11

    Predict JavaScript 如果/else 输出

    Predict 输出的 JavaScript 如果/else 语句使用 comparison.

    预测输出 入门
  12. 12

    完整如果条件

    Fill in 空白到 制作如果条件真 当 temperature 是 above 30.

    填空题 入门
  13. 13

    Predict JavaScript 虽然循环输出

    Predict 输出的 JavaScript 虽然循环那个数量下.

    预测输出 入门
  14. 14

    Spot 无限循环

    Identify 常见 mistake 那个 causes JavaScript 虽然循环到 运行 forever.

    找错误 简单
  15. 15

    什么是 DOM?

    检查你的 conceptual 理解的 什么 DOM 是 in web development.

    概念检查 中等
  16. 16

    querySelector 测验

    测试你的 knowledge 的 querySelector 方法 for 选择 DOM 元素.

    单选题 中等
  17. 17

    什么是 Promise?

    检查你的 conceptual 理解的 什么 Promise 是 in JavaScript.

    概念检查 中等
  18. 18

    异步/等待 Keyword 测验

    测试你的 knowledge 的异步 and 等待 keywords in modern JavaScript.

    单选题 中等
  19. 19

    var 对比 let 作用域测验

    测试你的理解的 如何 var and let differ in scoping 在内块.

    单选题 简单
  20. 20

    Predict var Hoisting

    Predict 输出的 code 那个 uses var 变量之前它的 declaration.

    预测输出 中等
  21. 21

    Declare let 变量

    Fill in 空白到 declare 可变变量 in JavaScript.

    填空题 入门
  22. 22

    Spot const Reassignment 错误

    查找 mistake in code 那个 tries 到 reassign const 变量.

    找错误 简单
  23. 23

    var, let, const 概念检查

    检查你的理解的 differences 之间 var, let, and const.

    概念检查 中等
  24. 24

    Temporal Dead 区域测验

    测试你的 knowledge 的 temporal dead 区域使用 let and const.

    单选题 中等
  25. 25

    Predict typeof Results

    Predict 输出的 几个 typeof 检查 in JavaScript.

    预测输出 简单
  26. 26

    字符串 Concatenation 测验

    测试你的理解的 字符串 concatenation 使用 + 运算符.

    单选题 入门
  27. 27

    检查类型使用 typeof

    Fill in 空白到 检查如果值 是数字.

    填空题 入门
  28. 28

    Strict 对比 Loose Equality

    检查你的理解的 == 对比 === in JavaScript.

    概念检查 中等
  29. 29

    Predict 类型 Coercion

    Predict 输出的 JavaScript 类型 coercion in comparisons.

    预测输出 中等
  30. 30

    Spot Loose Equality Bug

    查找 bug caused 通过 using loose equality (==) 相反的 strict (===).

    找错误 简单
  31. 31

    函数 Declaration 对比表达式

    测试你的 knowledge 的函数 declarations 对比函数表达式.

    单选题 中等
  32. 32

    Predict 默认参数

    Predict 输出的 函数 using 默认参数.

    预测输出 简单
  33. 33

    编写 Arrow 函数

    Fill in 空白到 完整 arrow 函数那个 squares 数字.

    填空题 入门
  34. 34

    Spot Missing 返回

    查找 bug in 函数那个 uses curly braces 但 forgets 到返回.

    找错误 简单
  35. 35

    闭包概念检查

    检查你的理解的 闭包 in JavaScript.

    概念检查 中等
  36. 36

    Predict 闭包输出

    Predict 输出的 闭包那个 captures 计数器变量.

    预测输出 中等
  37. 37

    REST 参数测验

    测试你的理解的 REST 参数 in JavaScript 函数.

    单选题 中等
  38. 38

    Predict 回调 Execution

    Predict 输出的 函数那个接受回调.

    预测输出 简单
  39. 39

    数组映射对比 forEach 测验

    测试你的理解的 difference 之间映射 and forEach.

    单选题 中等
  40. 40

    Predict 数组映射输出

    Predict result 的映射 over 数组使用 transformation.

    预测输出 简单
  41. 41

    Predict 数组筛选输出

    Predict result 的筛选数组使用 predicate.

    预测输出 简单
  42. 42

    Predict 数组 reduce 输出

    Predict result 的 reducing 数组到 单个值.

    预测输出 中等
  43. 43

    数组 Destructuring Fill

    Fill in 空白到 destructure 首先 two 元素的 数组.

    填空题 简单
  44. 44

    Spot splice 对比 slice Mistake

    查找 mistake in code 那个 confuses splice 使用 slice.

    找错误 中等
  45. 45

    数组引用概念

    检查你的理解的 数组引用语义 in JavaScript.

    概念检查 中等
  46. 46

    数组 indexOf 测验

    测试你的 knowledge 的 indexOf 方法 on 数组.

    单选题 简单
  47. 47

    Predict Spread 运算符

    Predict 输出的 using spread 运算符到 组合数组.

    预测输出 简单
  48. 48

    数组查找 Fill

    Fill in 空白到 查找首先元素 greater than 10.

    填空题 简单
  49. 49

    对象方法测验

    测试你的理解的 方法 shorthand 语法 in 对象.

    单选题 简单
  50. 50

    Predict 对象 Destructuring

    Predict 输出的 对象 destructuring 使用 renamed 属性.

    预测输出 简单
  51. 51

    Computed 属性 Fill

    Fill in 空白到 use 变量 as 对象键.

    填空题 中等
  52. 52

    Spot 这个 Binding Mistake

    查找 bug 哪里 `这个` loses 它的 binding 当方法是 extracted.

    找错误 中等
  53. 53

    原型概念检查

    检查你的理解的 原型链 in JavaScript.

    概念检查 中等
  54. 54

    Predict 对象.键输出

    Predict 输出的 对象.键 on 对象.

    预测输出 简单
  55. 55

    对象 Spread 测验

    测试你的理解的 spread 运算符使用对象.

    单选题 中等
  56. 56

    Predict Nested 对象 Access

    Predict 输出的 accessing nested 对象属性.

    预测输出 简单
  57. 57

    Predict Ternary 输出

    Predict 输出的 ternary conditional 表达式.

    预测输出 简单
  58. 58

    切换语句测验

    测试你的 knowledge 的切换语句 fall-通过 behavior.

    单选题 中等
  59. 59

    完整 Comparison

    Fill in 空白到 检查如果值 是 neither 空 nor undefined.

    填空题 简单
  60. 60

    Spot Assignment in 如果

    查找 bug 哪里 = 是 used 相反的 == in 如果条件.

    找错误 简单
  61. 61

    Predict for 循环输出

    Predict 输出的 标准 for 循环那个总和数字.

    预测输出 简单
  62. 62

    Predict for...的输出

    Predict 输出的 for...的循环 over 数组.

    预测输出 简单
  63. 63

    for...in 对比 for...的测验

    测试你的理解的 difference 之间 for...in and for...的.

    单选题 中等
  64. 64

    完整虽然循环

    Fill in 空白到 制作虽然循环运行精确地 3 次数.

    填空题 简单
  65. 65

    Spot Off-通过-One 错误

    查找 off-通过-one bug in 循环那个处理数组.

    找错误 简单
  66. 66

    break 对比 continue 概念

    检查你的理解的 break and continue in 循环.

    概念检查 简单
  67. 67

    getElementById 测验

    测试你的 knowledge 的 getElementById DOM 方法.

    单选题 简单
  68. 68

    Predict textContent 更新

    Predict 什么 happens 当 textContent 是设置 on DOM 元素.

    预测输出 简单
  69. 69

    完整 addEventListener

    Fill in 空白到 attach 点击事件监听器到 button.

    填空题 简单
  70. 70

    Spot innerHTML 对比 textContent Issue

    查找 security issue 使用 using innerHTML for 用户输入.

    找错误 中等
  71. 71

    事件 Bubbling 概念

    检查你的理解的 事件 bubbling in DOM.

    概念检查 中等
  72. 72

    classList 测验

    测试你的 knowledge 的 classList API for managing CSS 类.

    单选题 简单
  73. 73

    Predict Promise.然后链

    Predict 输出的 Promise.然后链.

    预测输出 中等
  74. 74

    Promise.所有测验

    测试你的理解的 Promise.所有 behavior.

    单选题 中等
  75. 75

    Microtask 概念检查

    检查你的理解的 microtasks and 事件循环.

    概念检查 中等
  76. 76

    Predict 异步/等待输出

    Predict 输出的 异步函数 using 等待.

    预测输出 中等
  77. 77

    Spot Unhandled Rejection

    查找 bug 哪里 Promise rejection 是不 caught.

    找错误 中等
  78. 78

    完整 try/catch for 异步

    Fill in 空白到 catch 错误从 异步操作.

    填空题 中等
  79. 79

    Predict Template Literal

    Predict 输出的 template literal 使用 embedded 表达式.

    预测输出 简单
  80. 80

    Destructuring 使用默认测验

    测试你的 knowledge 的 destructuring 使用默认值.

    单选题 中等
  81. 81

    Spread 到复制数组

    Fill in 空白到 创建 shallow 复制的 数组 using spread.

    填空题 简单
  82. 82

    类概念检查

    检查你的理解的 ES6 类语法.

    概念检查 中等
  83. 83

    Predict Generator 输出

    Predict 输出的 generator 函数.

    预测输出 中等
  84. 84

    Symbol Uniqueness 测验

    测试你的理解的 Symbol uniqueness.

    单选题 中等
  85. 85

    Spot 映射对比对象 Mistake

    查找 issue 使用 using plain 对象当 映射会 是 better.

    找错误 中等
  86. 86

    设置概念检查

    检查你的理解的 设置数据结构.

    概念检查 简单
  87. 87

    Predict JSON.parse 输出

    Predict 输出的 parsing JSON 字符串.

    预测输出 简单
  88. 88

    错误 Handling 测验

    测试你的 knowledge 的 try/catch/最后 behavior.

    单选题 中等
  89. 89

    localStorage Fill

    Fill in 空白到 保存值 到 localStorage.

    填空题 简单
  90. 90

    Spot parseInt Radix Issue

    查找 bug 使用 parseInt 当字符串开始使用 0.

    找错误 中等
  91. 91

    Hoisting 概念检查

    检查你的理解的 hoisting in JavaScript.

    概念检查 中等
  92. 92

    Predict Coercion in 条件

    Predict 哪个值 是 truthy and 哪个是 falsy.

    预测输出 中等
  93. 93

    字符串方法测验

    测试你的 knowledge 的常见字符串方法.

    单选题 简单
  94. 94

    Predict 数组排序输出

    Predict 输出的 排序 numeric 数组不使用 comparator.

    预测输出 中等
  95. 95

    Regex 测试 Fill

    Fill in 空白到 测试如果字符串 matches digit 模式.

    填空题 中等
  96. 96

    Spot Floating 点 Precision

    查找 issue 使用 floating 点 arithmetic in JavaScript.

    找错误 中等
  97. 97

    通过通过引用概念

    检查你的理解的 通过-通过-引用 for 对象.

    概念检查 中等
  98. 98

    Predict Bitwise 操作

    Predict 输出的 bitwise 操作.

    预测输出 中等
  99. 99

    Date 对象测验

    测试你的 knowledge 的 JavaScript Date 对象.

    单选题 简单
  100. 100

    事件循环概念检查

    检查你的理解的 JavaScript 事件循环.

    概念检查 中等
  101. 101

    let 与 const

    哪个关键字声明不能重新赋值的变量?

    单选题 入门
  102. 102

    typeof 数组

    typeof [] 返回什么?

    单选题 入门
  103. 103

    pop 后数组长度

    [1,2,3].pop() 后数组长度是多少?

    单选题 入门
  104. 104

    字符串 split 结果

    "a,b,c".split(",") 返回什么?

    单选题 简单
  105. 105

    Object keys 方法

    Object.keys({a:1,b:2}) 返回什么?

    单选题 简单
  106. 106

    Promise 状态

    哪个不是有效的 Promise 状态?

    单选题 中等
  107. 107

    var 函数作用域

    var 变量在哪里可访问?

    单选题 中等
  108. 108

    数组 map 返回

    [1,2].map(x => x*2) 返回什么?

    单选题 简单
  109. 109

    严格相等结果

    0 === "" 返回什么?

    单选题 入门
  110. 110

    for...of 与 for...in

    哪个循环遍历数组值(非索引)?

    单选题 简单
  111. 111

    async/await 结果

    async 函数中 await 做什么?

    单选题 中等
  112. 112

    数组 reduce 求和

    [1,2,3].reduce((a,b) => a+b, 0) 返回什么?

    单选题 中等
  113. 113

    对象浅拷贝

    Object.assign({}, obj) 创建什么?

    单选题 中等
  114. 114

    闭包变量捕获

    闭包中外部变量何时访问?

    单选题 中等
  115. 115

    事件循环本质

    JavaScript 事件循环做什么?

    单选题 中等
  116. 116

    数组默认排序

    [10,2,1].sort() 返回什么?

    单选题 中等
  117. 117

    模板字符串多行

    模板字符串能跨多行吗?

    单选题 简单
  118. 118

    JSON undefined 处理

    JSON.stringify 中 undefined 属性会怎样?

    单选题 中等
  119. 119

    数组解构交换

    能用 [a, b] = [b, a] 交换变量吗?

    单选题 简单
  120. 120

    setTimeout 最小延迟

    浏览器中 setTimeout 的最小延迟是多少?

    单选题 中等
  121. 121

    对象属性简写

    x=1, y=2 时 { x, y } 表示什么?

    单选题 简单
  122. 122

    数组 includes 方法

    [1,2,3].includes(2) 返回什么?

    单选题 入门
  123. 123

    可选链结果

    null?.x 返回什么?

    单选题 简单
  124. 124

    Promise.all 行为

    Promise.all 中一个 Promise 拒绝会怎样?

    单选题 中等
  125. 125

    Number.isInteger

    Number.isInteger(3.0) 返回什么?

    单选题 简单
  126. 126

    数组 flat 方法

    [1,[2,[3]]].flat() 返回什么?

    单选题 中等
  127. 127

    字符串 includes

    "hello world".includes("world") 返回什么?

    单选题 入门
  128. 128

    剩余参数

    function f(...args) { return args; } 对 f(1,2,3) 返回什么?

    单选题 简单
  129. 129

    Symbol 唯一性

    Symbol() === Symbol() 返回什么?

    单选题 中等
  130. 130

    生成器函数

    生成器函数返回什么?

    单选题 中等
  131. 131

    数组 push 长度

    预测输出。

    预测输出 入门
  132. 132

    对象访问

    预测输出。

    预测输出 入门
  133. 133

    三元结果

    预测输出。

    预测输出 入门
  134. 134

    循环计数

    预测输出。

    预测输出 简单
  135. 135

    数组 join

    预测输出。

    预测输出 简单
  136. 136

    字符串 repeat

    预测输出。

    预测输出 简单
  137. 137

    对象展开

    预测输出。

    预测输出 简单
  138. 138

    数组 filter 计数

    预测输出。

    预测输出 简单
  139. 139

    Math.max

    预测输出。

    预测输出 简单
  140. 140

    typeof 函数

    预测输出。

    预测输出 入门
  141. 141

    数组 find

    预测输出。

    预测输出 简单
  142. 142

    字符串 slice

    预测输出。

    预测输出 简单
  143. 143

    Object.entries

    预测输出。

    预测输出 中等
  144. 144

    Promise.resolve

    预测输出。

    预测输出 中等
  145. 145

    数组 concat

    预测输出。

    预测输出 简单
  146. 146

    嵌套对象访问

    预测输出。

    预测输出 中等
  147. 147

    数组 indexOf

    预测输出。

    预测输出 简单
  148. 148

    布尔转换

    预测输出。

    预测输出 中等
  149. 149

    数组 reverse

    预测输出。

    预测输出 简单
  150. 150

    字符串 charAt

    预测输出。

    预测输出 入门

动手做项目

通过引导式项目应用所学,含起始代码与解决方案。

查看项目