React Native

JavaScript Essentials

Variables (let/const/var), types, closures, this, arrow functions, destructuring, spread/rest

25 câu hỏi phỏng vấn·
Junior
1

What is the main difference between let and var in JavaScript?

Câu trả lời

let has block scope while var has function scope. This means a variable declared with let is only accessible within the block where it's defined (between curly braces), whereas var is accessible throughout the entire function. This difference is crucial to avoid bugs related to hoisting and variables leaking outside their intended context.

2

What happens when accessing a let variable before its declaration?

Câu trả lời

A ReferenceError is thrown because the variable is in the Temporal Dead Zone (TDZ). Unlike var which is hoisted with undefined value, let variables are hoisted but remain inaccessible until their declaration. This temporal dead zone helps detect programming errors where a variable is used before being defined.

3

What is the main characteristic of const in JavaScript?

Câu trả lời

const prevents reference reassignment but not content mutation. For primitive types, this means the value cannot change. For objects and arrays, the reference stays the same but properties or elements can be modified. Using const by default is good practice as it expresses the intent not to reassign the variable.

4

What are the primitive types in JavaScript?

5

What is the result of typeof null in JavaScript?

+22 câu hỏi phỏng vấn

Nắm vững React Native cho lần phỏng vấn tiếp theo

Truy cập tất cả câu hỏi, flashcards, bài kiểm tra kỹ thuật, bài tập code review và mô phỏng phỏng vấn.

Bắt đầu miễn phí