Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function ExecuteRect(code)
- {
- function rectangle(wid,hei,col)
- {
- let obj = {
- width:0,
- height:0,
- color:0,
- calcArea:function(){return Number(this.height)*Number(this.width); }
- };
- obj.width = wid;
- obj.height = hei;
- obj.color = col;
- return obj;
- }
- let executable = eval(code);
- new Function(executable)();
- }
- let code =
- `let rect = rectangle(4, 5, 'red');
- console.log(rect.width);
- console.log(rect.height);
- console.log(rect.color);
- console.log(rect.calcArea());`;
- ExecuteRect(code);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement