You should put the command
in the first line of the script to invoke strict mode.
Let's rewrite our code in strict mode:
"use strict"; alert('text!');
For simplicity, I will not point out that the code works in strict mode in the future (but it is assumed that it takes place, and you always enable it).
Invoke strict mode in your script.