I'm trying to use strict mode in chrome console according to what I read these two method should work but only Method 1 is working. Is in Method 2 I'm doing something wrong or it is not possible to use strict mode like this.
Method 1:
(function f(){
'use strict';
function fn(text){herd=text; console.log(herd);}
fn("Hi Welcome");
})();
output of Method1
VM1139:3 Uncaught ReferenceError: herd is not defined
at fn (<anonymous>:3:23)
at f (<anonymous>:4:1)
at <anonymous>:5:3
Method 2:
'use strict';
function fnete(text) {as=text; console.log(as);}
'use strict'; fnete("hi");
output of method 2
hi