Phát triển Javascript - part 21

Tham khảo tài liệu 'phát triển javascript - part 21', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Strict Mode 173 results in only the last one to be reachable inside the function except through arguments in which all parameters are always reachable . Listing shows the new behavior compared to the current one. Listing Using the same identifier for more than one formal parameter test repeated identifiers in parameters function Syntax error in ES5 strict mode function es3VsEs5 a a a use strict return a true in ES3 assertEquals 6 es3VsEs5 2 3 6 Attempts to access the caller or callee properties of the arguments object will throw a TypeError in strict mode. In ES3 and non-strict ES5 the arguments object shares a dynamic relationship with formal parameters. Modify a formal parameter and the value in the corresponding index of the argument object is modified too. Modify a value of the arguments object and the corresponding parameter changes. In strict mode this relationship goes away and arguments is immutable as Listing exemplifies. Listing Relationship between arguments and formal parameters function switchArgs a b use strict var c b b a a c return . arguments TestCase ArgumentsParametersTest test should switch arguments function Passes on ES5 strict mode assertEquals 3 2 switchArgs 2 3 Passes on ES3 assertEquals 2 3 switchArgs 2 3 Download from 174 ECMAScript 5th Edition this is no longer coerced to an object in strict mode. In ES3 and non-strict ES5 this will be coerced to an object if it is not one already. For instance when using call or apply with function objects passing in null or undefined will no longer cause this inside the called function to be coerced into the global object. Neither will primitive values used as this be coerced to wrapper objects. Objects Properties and Variables eval and arguments cannot be used as identifiers in ES5 strict mode. Formal parameters variables the exception object in a try-catch statement and object property identifiers are all affected by this restriction. In ES3 .

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
5    77    2    21-05-2024
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.