return 与 finally

(function hello() {
try {
return console.log('return');
} catch (e) { } finally {
console.log('finally');
}
}());

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAksAAAA3CAIAAACToJnGAAAHp0lEQVR4nO2dsc7dNBTH/UaeEQ+AxMBcVVgMSEgMDCxIFeIBLPEaSAwMlhATDJXYKlQhsNSKgQJDBwoUJFR9Ra3MkMRxbCd2cpN7c9Pfb2lvrq9zHB+fv4+dfBEOAADgiIhLGwAAALAJUwr3x98vTqzdaGdPrOIasU4b54zTdY232gm5uwulhFPm0kbAXtmn0+6CZvhbJ4W78ABKbNB683Ma5YRaWKDRi9jI6kCaZVThnt28vHXnt7vf/bu4aquvP0QmF7fGRVQ38rWscnGt9hcpzPX33VmYHTJOG67rsMirI/botCXO01l++Fu9icLNEoDYBuPkGUSulNhkC/R6kRhZGUizTOVwX3z99Padnx8+eras6kFPWCeFE6Ig71MkHWnU8t4qTjScc0o4IfqTWl1lf+RSNYNq5WCxSgy9uMLtQQkmqfSHkMijlmGUE2E9M3OFZV6dcl0Kd7bO8sPf6lx0SsLgrCCWtmLayKwNG+luyDKFC0NlauTi7LOwD/fhp49u33n45Ol/c+u1enDdo48LMGrlkKcq3D01u/irqIBRZX9aN1isc6EurXCrd/dG1HhRyOkDYe4Za2xYUOd1KVzDGTpr+hSn9356itl1Wqc2TuOKQS8tELciMbImkGYpKNzjJzdvffDjOx/bm+cvZ9UbGqRlO+sUwpkgf9LSSd3Oa1QzMw0S/HCi2tegBnX2F2U4OWpO0UxwxiK1SgqoJMucjgXxbNplOqbof0atqSXRhWosVKZtmunaaMzklNY6ud0WS9NT0hnthGjnmNPdnXWYsIaa7o5OUXYYX6DLkDLdPfSH+BQjZiyPcaYfR+3cfNiPU62o82rbXdJ4fEWGrOq0KXvsrFz65bvD2zkhHlEYdFEQy4XBYisiI6tGd1KDlmvPJosBJCmQClhByE1tRl5QuCd/PX/jvfu3P7p/isKl9rXWdw7hs+n2V9bJYYG0huiIX6j1i7lKtFWN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1WtV96v5vdCdQ/THnnNWqe5WlLzmowWrZSNvgZwAAAONspXAD/ZLC0ytYSeFCKcsUAAAAmOQMCpeVpazCBbtzKBwAAJzGVvtwYb4WHPPbaG1i1xZpv5dS9vtv/ddNWaltuLUHAAAwCc/DAQDAMUHhAADgmKBwAABwTFA4AAA4JigcAAAcExQOAACOiXgAAABwRMjhAADgmKBwAABwTFA4AAA4JigcAAAcExQOAACOCQoHAADHZMcK178utcFqzVsFAACglq0UrnsDTve6HKvljNfeNL/2r9qJ3rUDAABQZiOFW+FNpf6tpyvWCQAArw4bKFz/AtMuCxu+udQoIZRS4UtS2xxtkKVNKFz3SlTTvRp1/UYAAMC1c7YcLjxiVCNlnYh131kt+0LTOZxRUtt0rw4AAKDlQgrXKVonYj7vq1U4Z7VUmntPAABgjD0oXJfSzcnhXPAzAACAlA0Uzm+qDXbe+iPdrpz1u2j+xksphwe6Tba+ykDUWKEEAIAJdvw83ARWS54dAACASa5T4QAAAEqgcAAAcEz+Bxbd/eHlcxX/AAAAAElFTkSuQmCC" alt="" />

有趣的是如果不加上方法名hello的话,return 语句会报错 not in a function

以前Java在争论return 和 finally 哪个先执行的问题,其实上面这个例子并不能证明return 比 finally先执行,因为return 后的方法会先执行。如果把return 纯粹当做一个结束语句,那必定还是finally先执行的。

上一篇:stm32 cortext-M3 类型对齐问题【worldsing笔记】


下一篇:C语言程序设计第二次作业—————顺序结构