strict mode
Exercises 1
1.Create a script that runs in non-strict mode but contains a function that runs in strict mode.
Answer:
See the Pen strict mode by oscar (@nopity) on CodePen.
2.Create a file that enforces strict mode throughout the file.
Answer:
See the Pen strict mode by oscar (@nopity) on CodePen.
Exercises 2
1.Create a function that generates a SyntaxError when run in strict mode.
Answer:
'use strict';
function bob(x) {
delete x;
return x;
}
2.Define a property of an object that throws a TypeError if you attempt to delete it.
Answer:
var dog = {};
Object.defineProperty(dog, 'prop' , {configurable: false});
delete dog.prop;
Exercises 3
1.Create a function that accepts two octal numbers and returns the sum of them. The function must not generate any errors in strict mode.
Answer: