| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- //-------------------------------------------------------------------------------------------------------
- // Copyright (C) Microsoft. All rights reserved.
- // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
- //-------------------------------------------------------------------------------------------------------
- const a = 1;
- with({a:2}) {
- a++;
- print(a); // 3
- }
- try {
- with({b:2}) {
- a++;
- print(a);
- }
- }
- catch(e) {
- print(e); // TypeError: Assignment to const
- }
- let foo1 = new Function(
- "with({a:2}) {" +
- " a++;" +
- " print(a);" +
- "}");
- foo1(); // 3
- let foo2 = new Function(
- "with({b:2}) {" +
- " a++;" +
- " print(a);" +
- "}");
- try {
- foo2();
- }
- catch(e) {
- print(e); // TypeError: Assignment to const
- }
- try {
- eval('let b = 3');
- a++;
- print(a);
- }
- catch(e) {
- print(e); // TypeError: Assignment to const
- }
- (function() {
- const a = 1;
- with({a:2}) {
- a++;
- print(a); // 3
- }
- try {
- with({b:2}) {
- a++;
- print(a);
- }
- }
- catch(e) {
- print(e); // TypeError: Assignment to const
- }
- try {
- eval('let b = 3');
- a++;
- print(a);
- }
- catch(e) {
- print(e); // TypeError: Assignment to const
- }
- })();
- function print(x) { WScript.Echo(x) }
|