Javascript is just the language. Its your runtime environment (browser) that is letting an unprivileged process consume resources like that without killing it.
I had a similar experience on macOS with Chrome Canary watching a YouTube movie full screen. My laptop simply froze, nothing, except a restart, worked.