var str1 = "\ function add1(a,b){\ return a+b;\ }\ console.log(add1(1,2));\ "; var str2 = [ 'function add2(a,b){', ' return a+b;', '}', 'console.log(add2(1,2));' ].join('\n'); var str3 = 'function add3(a,b){' + ' return a+b;'+ '}'+ 'console.log(add3(1,2));'; var str4 = ` //ES6 function add4(a,b){ return a+b; } console.log(add4(1,2)); `; eval(str1); eval(str2); eval(str3); eval(str4);
November 2024 S M T W T F S « Jan 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 -
Recent Posts
Recent Comments
Categories
Links