我最近圍繞JS代碼戳返回類型,我發現了以下注釋:明確設置的功能
/**
* Explicitly set the return type here to prevent the primitive being lost when using new
* @return {boolean}
*/
function giveMeABoolean(please) {
...
}
是怎麼回事?在JS中返回類型?我一直在網上搜索,無法找到任何關於此的信息。經過一些測試後,使用新沒有註釋時,原語確實丟失。任何人都可以解釋這個註釋如何工作?
註釋不改變行爲的。所有評論都被口譯員拋棄。 –