Funny how exploiting uninitialized variables is evil in (nonstrict) JavaScript but good in Awk. I agree that’s true, mind you, I just can’t pinpoint what about the languages’ designs makes it work in one case but not the other.
I believe Awk's semantic behaviour is a kindred spirit of Perl's autovivication[0].
It is often handy and sometimes can bite one in the proverbial backside.
For an opposite example, consider: a 1000 statement JS program is perfectly fine. A 1000 statement AWK script is very evil, most people would be saying it should be replaced with real language ASAP.
awk '!a[$0]++'
awk '/search/{n=2} n && n--'> The syntax of JavaScript 1.0 was directly modeled after the statement syntax of the C programming language with some AWK inspired embellishments.
(the rest of the section is also interesting in that respect).
[1] https://dl.acm.org/doi/10.1145/3386327 (CC-BY open access)