-1

When I do console.log(true); in content.js, the page's console displays true. However, when I make a function

test = () => console.log(true);

and then use the function in the page's console, it says that the function is not defined. How can I send that function into the page?

FULL CODE:

console.log(true); // prints true
var test = () => console.log(true); // console says test is undefined
window.test = test;
jackosaur
  • 285
  • 4
  • 6

1 Answers1

-1

you need to add var at the beginning of the function. And you have to call it as test()

var test = () => console.log(true);
test();
//should return true
horrible
  • 117
  • 1
  • 8