Hello,

PHP situation: When a given endpoint of my API is reached, a json string is outputed for being consumed. I sent the proper headers, echo the string and exit the script using die(). I could do it more brutally just by doing die($json_string);

I was wondering if the same could be done using javascript. I know that throw new Error(json_string); would pretty much do it. But is that good practice? Would window.stop be of any use?

I expect questions such as: why you wanna do that? why don't you do it in php? answer: for the sake of experimenting and learning.