For years the only bit of feedback web developers could get was via alert("{str}")
calls. These days we have the web console but, in rare cases, we don't have a console and alert
calls are our only window into a value at a given time.
多年来,Web开发人员只能通过alert("{str}")
调用获得反馈。 如今,我们拥有Web控制台,但在极少数情况下,我们没有控制台,并且alert
呼叫是我们在给定时间访问值的唯一窗口。
One problem: if an alert
sneaks into production code, your site looks like it's been hacked. Your site looks like it's malware! To prevent any of those issues, you can add this snippet to your production build:
一个问题:如果alert
潜入生产代码中,则您的网站看起来像被黑了。 您的网站看起来像是恶意软件! 为防止出现任何此类问题,您可以将此代码段添加到生产版本中:
window.alert = console.log
This tiny line of JavaScript could save your site from catastrophe. There are many cases for overriding native functionality and this is a great example!
这行很小JavaScript可以使您的网站免于灾难。 在很多情况下,本机功能都将被覆盖,这是一个很好的例子!