Tôi không thể hiểu tại sao window
là dưới self
và self
là dưới đối tượng window
.Đối tượng lạ tự trong đối tượng cửa sổ
nếu bạn truy cập công cụ dành cho nhà phát triển hoặc Firebug và viết window
bạn nhận được DOM window
đối tượng self
nằm trong đối tượng này. Phần kỳ lạ là window
là dưới self
một lần nữa!
Bạn có thể viết
window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self
và bạn vẫn có được window
đối tượng!
Làm thế nào ?!
Xem http://stackoverflow.com/questions/6145544/self-document-this-top-window – Shaz
Vì vậy, bạn chưa thấy tự tham khảo trước đây? Nó khá phổ biến trong mẫu đơn ví dụ và vì javascript thiếu các biến riêng tư trực tiếp, bạn có thể truy cập vào quảng cáo đó ... Tôi không nói trường hợp này là "IS", nhưng là trường hợp sử dụng hoặc giải thích lý do tại sao nó có thể là – PhD
Đây là một đối tượng không phải là một hàm. ngay cả khi có một đối tượng tự tham chiếu tạo phương thức trong JavaScript, tôi sẽ rất vui khi biết điều đó. – Mohsen