Tôi đã tìm thấy dòng này trong đặc tả giải thích hành vi.
3. Else if Type(thisArg) is not Object, set the
ThisBinding to ToObject(thisArg).
Về bản chất giá trị false
sẽ được chuyển thành đối tượng boolean. Ứng dụng đầu tiên của toán tử !
sẽ chuyển đổi đối tượng thành true
rồi đảo ngược thành false
. Đơn đăng ký thứ hai của nhà điều hành !
sẽ đảo ngược false
thành true
.
Toàn văn
10.4.3 Entering Function Code
The following steps are performed when control enters the
execution context for function code contained in function
object F, a caller provided thisArg, and a caller provided argumentsList:
1. If the function code is strict code, set the ThisBinding to thisArg.
2. Else if thisArg is null or undefined,
set the ThisBinding to the global object.
3. Else if Type(thisArg) is not Object, set the
ThisBinding to ToObject(thisArg).
4. Else set the ThisBinding to thisArg.
5. Let localEnv be the result of calling NewDeclarativeEnvironment
passing the value of the [[Scope]] internal
property of F as the argument.
6. Set the LexicalEnvironment to localEnv.
7. Set the VariableEnvironment to localEnv.
8. Let code be the value of F‘s [[Code]] internal property.
9. Perform Declaration Binding Instantiation using the function code
code and argumentsList as described in
Tôi thích điều đó! WTF javascript ?! – Prestaul
vì vậy tôi đoán câu trả lời cho câu hỏi đóng của tôi, là khi nó là một 'Boolean'. – Domenic