Trang chủ
Frontend
Backend
DevOps
Xem thêm
Câu hỏi phỏng vấn
Tài liệu lập trình
Tin tức
Cộng đồng
Youtube
Phỏng vấn
Angular
Khóa học Angular
Javascript
Khóa học Javascript
React Native
Khóa học React Native
Java
Khóa học Java nền tảng
Spring Boot
Khóa học Spring Boot
C
Khóa học C nền tảng
Go
Khóa học Go cơ bản
Devops
Docker
Khóa học Docker cơ bản
AWS
Khóa học Cloud cơ bản
React.js
HTML
CSS
Typescript
Python
NodeJs
ReactJs
VueJs
1603 câu hỏi phỏng vấn Full-Stack, Coding & System Design Interview
Bộ lọc:
Trong javascript có bao nhiêu phạm vi của biến, hãy giải thích nó?
So sánh == và === trong Javascript
==
===
Sự khác biệt của biến dùng var, let và const
var
let
const
Cho biết kết quả của đoạn code dưới đây?
console.log(typeof typeof 1);
Object trong Javascript là gì?
Sự khác biệt giữa các kiểu dữ liệu trong JavaScript?
Kể các cách khai báo 1 biến trong Javascript?
Kể tên các kiểu dữ liệu cơ bản trong Javascript
Strict mode trong JavaScript là gì?
JavaScript là ngôn ngữ kiểu tĩnh hay kiểu động?
Array trong Javascript là gì?
Sự khác nhau giữa null và undefined trong Javascript?
null
undefined
Giải thích về ép kiểu ngầm trong JavaScript?
Toán tử typeof trong Javascript là gì?
typeof
Lập trình bất đồng bộ trong Javascript là gì?
Kết quả đoạn code sau là gì?
const person = { name: "Lydia" }; Object.defineProperty(person, "age", { value: 21 }); console.log(person); console.log(Object.keys(person));
{ name: "Lydia", age: 21 }
["name", "age"]
["name"]
{ name: "Lydia"}
["age"]
Javascript là ngôn ngữ pass-by-reference hay pass-by-value không?
Hàm anonymous là gì và khi nào nên sử dụng?
const shape = { radius: 10, diameter() { return this.radius * 2; }, perimeter: () => 2 * Math.PI * this.radius, }; shape.diameter(); shape.perimeter();
20
62.83185307179586
NaN
63
const { name: myName } = { name: "Lydia" }; console.log(name);
"Lydia"
"myName"
ReferenceError
let greeting; greetign = {}; // Lỗi đánh máy! console.log(greetign);
{}
ReferenceError: greetign is not defined
Viết một hàm có tên lucky_sevens nhận một mảng các số nguyên và trả về giá trị true nếu ba phần tử liên tiếp bất kỳ có tổng bằng 7.
lucky_sevens
true
Đây có phải là một pure function không?
function sum(a, b) { return a + b; }
Điểm khác nhau giữa method GET và method POST?
GET
POST
Sự khác biệt giữa throw Error('msg') so với throw new Error('msg') là gì?
throw Error('msg')
throw new Error('msg')
function sayHi() { console.log(name); console.log(age); var name = "Lydia"; let age = 21; } sayHi();
Lydia
21
console.log(String.raw`Hello world`);
Hello world!
Hello
world
Hello world
const box = { x: 10, y: 20 }; Object.freeze(box); const shape = box; shape.x = 100; console.log(shape);
{ x: 100, y: 20 }
{ x: 10, y: 20 }
{ x: 100 }
const myPromise = () => Promise.resolve("I have resolved!"); function firstFunction() { myPromise().then((res) => console.log(res)); console.log("second"); } async function secondFunction() { console.log(await myPromise()); console.log("second"); } firstFunction(); secondFunction();
I have resolved!
second
Coercion trong JavaScript là gì?
Coercion
async function getData() { return await Promise.resolve("I made it!"); } const data = getData(); console.log(data);
"I made it!"
Promise {<resolved>: "I made it!"}
Promise {<pending>}
function Car() { this.make = "Lamborghini"; return { make: "Maserati" }; } const myCar = new Car(); console.log(myCar.make);
"Lamborghini"
"Maserati"
TypeError
Promise.resolve(5);
5
Promise {<pending>: 5}
Promise {<fulfilled>: 5}
Error
Giải thích về phương thức call(), aplly() và bind()?
call()
aplly()
bind()
Giá trị nào của 'method' sẽ được trả về với log '{ name: "Lydia", age: 22 }'?
log '{ name: "Lydia", age: 22 }'
const keys = ["name", "age"]; const values = ["Lydia", 22]; const method = /* ?? */ Object[method]( keys.map((_, i) => { return [keys[i], values[i]]; }), ); // { name: "Lydia", age: 22 }
entries
values
fromEntries
forEach
Hàm setInterval trả về cái gì?
setInterval(() => console.log("Hi"), 1000);
let c = { greeting: "Hey!" }; let d; d = c; c.greeting = "Hello"; console.log(d.greeting);
Hey
let a = 3; let b = new Number(3); let c = 3; console.log(a == b); console.log(a === b); console.log(b === c);
false
const add = () => { const cache = {}; return (num) => { if (num in cache) { return `From cache! ${cache[num]}`; } else { const result = num + 10; cache[num] = result; return `Calculated! ${result}`; } }; }; const addFunction = add(); console.log(addFunction(10)); console.log(addFunction(10)); console.log(addFunction(5 * 2));
Calculated! 20
From cache! 20
for (var i = 0; i < 3; i++) { setTimeout(() => console.log(i), 1); } for (let i = 0; i < 3; i++) { setTimeout(() => console.log(i), 1); }
0 1 2
3 3 3
+true; !"Lydia";
1
Cái nào đúng?
const bird = { size: "small", }; const mouse = { name: "Mickey", small: true, };
mouse.bird.size
mouse[bird.size]
mouse[bird["size"]]
Thuộc tính NaN trong JavaScript là gì?
Cách lặp các phần tử của mảng trong Javascript?
function addToList(item, list) { return list.push(item); } const result = addToList("apple", ["banana"]); console.log(result);
['apple', 'banana']
2
Làm sao để clone một mảng?
Điều gì sẽ xảy ra khi chúng ta làm thế này?
function bark() { console.log("Woof!"); } bark.animal = "dog";
SyntaxError
Cách để lặp qua các thuộc tính đối tượng trong Javascript?
console.log("❤️" === "❤️");
class Chameleon { static colorChange(newColor) { this.newColor = newColor; return this.newColor; } constructor({ newColor = "green" } = {}) { this.newColor = newColor; } } const freddie = new Chameleon({ newColor: "purple" }); freddie.colorChange("orange");
orange
purple
green
Giải thích về phép gán quá giá trị và phép gán qua tham chiếu?
Bạn nghĩ gì về AMD (Asynchronous Module Definition) và CommonJS?
const set = new Set([1, 1, 2, 3, 4]); console.log(set);
[1, 1, 2, 3, 4]
[1, 2, 3, 4]
{1, 1, 2, 3, 4}
{1, 2, 3, 4}
Anonymous Function thường dùng cho trường hợp nào?
Ưu điểm và nhược điểm của việc sử dụng use strict là gì?
use strict
Lợi ích của việc sử dụng spread trong ES6 so với rest như thế nào?
Giá trị trả về là gì?
const firstPromise = new Promise((res, rej) => { setTimeout(res, 500, "one"); }); const secondPromise = new Promise((res, rej) => { setTimeout(res, 100, "two"); }); Promise.race([firstPromise, secondPromise]).then(res => console.log(res));
"one"
"two"
"two" "one"
"one" "two"
function getInfo(member, year) { member.name = "Lydia"; year = "1998"; } const person = { name: "Sarah" }; const birthYear = "1997"; getInfo(person, birthYear); console.log(person, birthYear);
{ name: "Lydia" }, "1997"
{ name: "Sarah" }, "1998"
{ name: "Lydia" }, "1998"
{ name: "Sarah" }, "1997"
Sự khác biệt giữa các Host objects và Native objects là gì?
// counter.js let counter = 10; export default counter;
// index.js import myCounter from "./counter"; myCounter += 1; console.log(myCounter);
10
11
Làm thế nào để so sánh hai object trong JavaScript?
So sánh sự khác nhau của forEach() và map()?
forEach()
map()
const settings = { username: "lydiahallie", level: 19, health: 90, }; const data = JSON.stringify(settings, ["level", "health"]); console.log(data);
"{"level":19, "health":90}"
"{"username": "lydiahallie"}"
"["level", "health"]"
"{"username": "lydiahallie", "level":19, "health":90}"
const one = false || {} || null; const two = null || false || ""; const three = [] || 0 || true; console.log(one, two, three);
[]
""
Bạn biết gì về sự kiện load trong Javascript?
function* generator(i) { yield i; yield i * 2; } const gen = generator(10); console.log(gen.next().value); console.log(gen.next().value);
[0, 10], [10, 20]
20, 20
10, 20
0, 10 and 10, 20
const list = [1 + 2, 1 * 2, 1 / 2]; console.log(list);
["1 + 2", "1 * 2", "1 / 2"]
["12", 2, 0.5]
[3, 2, 0.5]
[1, 1, 1]
Giải thích về bubbling event và cách để ngăn chặn nó?
bubbling event
let randomValue = { name: "Lydia" }; randomValue = 23; if (!typeof randomValue === "string") { console.log("It's not a string!"); } else { console.log("Yay it's a string!"); }
It's not a string!
Yay it's a string!
class Dog { constructor(name) { this.name = name; } } Dog.prototype.bark = function () { console.log(`Woof I am ${this.name}`); }; const pet = new Dog("Mara"); pet.bark(); delete Dog.prototype.bark; pet.bark();
"Woof I am Mara"
Làm sao để deep-freeze một đối tượng trong JavaScript?
deep-freeze
Con trỏ This trong javascript được dùng để làm gì?
This
Sự khác biệt giữa shim và polyfill trong Javascript là gì?
shim
polyfill
Nêu một số trường hợp không nên sử dụng Arrow Functions trong ES6?
function Person(firstName, lastName) { this.firstName = firstName; this.lastName = lastName; } const member = new Person("Lydia", "Hallie"); Person.getFullName = function () { return `${this.firstName} ${this.lastName}`; }; console.log(member.getFullName());
Lydia Hallie
Từ khóa new trong JavaScript là gì?
new
Sự khác biệt giữa null, undefined hoặc undeclared là gì?
undeclared
const user = { email: "my@email.com", updateEmail: (email) => { this.email = email; }, }; user.updateEmail("new@email.com"); console.log(user.email);
my@email.com
new@email.com
IIFEs (Immediately Invoked Function Expressions) là gì?
const set = new Set(); set.add(1); set.add("Lydia"); set.add({ name: "Lydia" }); for (let item of set) { console.log(item + 2); }
3
7
Lydia2
[object Object]2
"12"
let number = 0; console.log(number++); console.log(++number); console.log(number);
0
Giải thích về Scope và Scope Chain trong Javascript?
const colorConfig = { red: true, blue: false, green: true, black: true, yellow: false, }; const colors = ["pink", "red", "blue"]; console.log(colorConfig.colors[1]);
Giải thích cách hoạt động của JSONP và tại sao nó không thực sự là Ajax?
Có thể reset một generator ES6 về state ban đầu của nó không?
Hạn chế của phương thức private trong JavaScript là gì?
private
let person = { name: "Lydia" }; const members = [person]; person = null; console.log(members);
[null]
[{}]
[{ name: "Lydia" }]
const promise1 = Promise.resolve("First"); const promise2 = Promise.resolve("Second"); const promise3 = Promise.reject("Third"); const promise4 = Promise.resolve("Fourth"); const runPromises = async () => { const res1 = await Promise.all([promise1, promise2]); const res2 = await Promise.all([promise3, promise4]); return [res1, res2]; }; runPromises() .then((res) => console.log(res)) .catch((err) => console.log(err));
[['First', 'Second'], ['Fourth']]
[['First', 'Second'], ['Third', 'Fourth']]
[['First', 'Second']]
'Third'
Output của đoạn code dưới đây là gì?
var x = 1; var output = (function () { delete x; return x; })(); console.log(output);
3 giai đoạn của event propagation là gì?
event propagation
const numbers = [1, 2, 3, 4, 5]; const [y] = numbers; console.log(y);
[[1, 2, 3, 4, 5]]
[1, 2, 3, 4, 5]
[1]
const createMember = ({ email, address = {} }) => { const validEmail = /.+@.+..+/.test(email); if (!validEmail) throw new Error("Valid email pls"); return { email, address: address ? address : null, }; }; const member = createMember({ email: "my@email.com" }); console.log(member);
{ email: "my@email.com", address: null }
{ email: "my@email.com" }
{ email: "my@email.com", address: {} }
{ email: "my@email.com", address: undefined }
Khi nào cần sử dụng async và defer trong javascript?
async
defer
let num = 10; const increaseNumber = () => num++; const increasePassedNumber = number => number++; const num1 = increaseNumber(); const num2 = increasePassedNumber(num1); console.log(num1); console.log(num2);
12
Giải thích sự khác biệt giữa undefined và not defined trong JavaScript?
not defined
(() => { let x = (y = 10); })(); console.log(typeof x); console.log(typeof y);
"undefined", "number"
"number", "number"
"object", "number"
"number", "undefined"
Yêu cầu bạn hãy xóa các phần tử duplicate trong mảng, bạn sẽ làm như thế nào?
Sự khác nhau giữa bind, call và apply trong Javascript?
bind
call
apply
Sự khác biệt giữa từ khóa await và từ khóa yield là gì?
await
yield
function getPersonInfo(one, two, three) { console.log(one); console.log(two); console.log(three); } const person = "Lydia"; const age = 21; getPersonInfo`${person} is ${age} years old`;
["", " is ", " years old"]
Phép toán này dùng để làm gì?
JSON.parse();
Sự khác biệt giữa Map và WeakMap trong ES6 là gì?
Map
WeakMap
function compareMembers(person1, person2 = person) { if (person1 !== person2) { console.log("Not the same!"); } else { console.log("They are the same!"); } } const person = { name: "Lydia" }; compareMembers(person);
Not the same!
They are the same!
const name = "Lydia"; age = 21; console.log(delete name); console.log(delete age);
Generator trong Javascript là gì?
Làm thế nào có thể ghi ra giá trị giống như trong comment khi console.log?
console.log
function* startGame() { const answer = yield "Do you love JavaScript?"; if (answer !== "Yes") { return "Oh wow... Guess we're gone here"; } return "JavaScript loves you back ❤️"; } const game = startGame(); console.log(/* 1 */); // Do you love JavaScript? console.log(/* 2 */); // JavaScript loves you back ❤️
game.next("Yes").value
game.next().value
game.next.value("Yes")
game.next.value()
function sum(a, b) { return a + b; } sum(1, "2");
Symbol trong ES6 là gì?
Symbol
So sánh sự khác nhau giữa Object.freeze() và const?
Object.freeze()
function Person(firstName, lastName) { this.firstName = firstName; this.lastName = lastName; } const lydia = new Person("Lydia", "Hallie"); const sarah = Person("Sarah", "Smith"); console.log(lydia); console.log(sarah);
Person {firstName: "Lydia", lastName: "Hallie"}
Person {firstName: "Sarah", lastName: "Smith"}
Sự khác nhau giữa Anonymous function và Named function là gì?
function getAge() {