prototype là thuộc tính của hàm khởi tạo, chứa object sẽ trở thành prototype cho mọi instance tạo bởi new. __proto__ (chuẩn hoá là Object.getPrototypeOf) là liên kết trên chính instance trỏ tới prototype của nó.
function User() {}
const u = new User();
Object.getPrototypeOf(u) === User.prototype; // trueKhi đọc u.foo, engine tìm trên chính u, rồi lần theo chuỗi __proto__ lên User.prototype, Object.prototype, tới null thì trả undefined.
class và Object.create cho ra cùng cơ chế, khác ở tiện ích:
class A { greet() {} }
const a = new A();
const proto = { greet() {} };
const b = Object.create(proto); // b.__proto__ === protoclass chỉ là cú pháp gọn trên prototype, nhưng thêm ràng buộc: phương thức không enumerable, thân class chạy ở strict mode, gọi thiếu new ném TypeError, và extends nối cả prototype instance lẫn prototype tĩnh.
Lưu ý thực tế: đổi prototype của một object đang sống (Object.setPrototypeOf) làm engine huỷ tối ưu hoá và chậm rõ rệt — tạo object mới đúng shape thay vì vá prototype.