Tại sao 2..toString()
trả lại 2
nhưng 2.toString()
ném lỗi này?Tại sao 2..toString() hoạt động?
Ví dụ:
console.log(2..toString()); // prints 2
// Firefox throws the error
// `SyntaxError: identifier starts immediately after numeric literal`
console.log(2.toString());
var x = 2;
console.log(x.toString()); // prints 2
// Firefox throws the error
//`TypeError: XML descendants internal method called on incompatible Number`
console.log(x..toString());
(2) .toString() mang lại kết quả mong đợi. (không phải là câu trả lời mà là một bài kiểm tra ...) –
Liệu IE có đưa ra lỗi không? – DevelopmentIsMyPassion
Tôi biết nhưng tại sao '2..toString()' cũng hoạt động? –