如何確定是否向 JavaScript 函式傳送了引數?
要確定是否向函式傳送了引數,請使用“default”引數。
示例
您可以嘗試執行以下內容來實現它
<!DOCTYPE html>
<html>
<body>
<script>
function display(arg1 = 'Tutorials', arg2 = 'Learning') {
document.write(arg1 + ' ' +arg2+"<br>");
}
display('Tutorials', 'Learning');
display('Tutorials');
display();
</script>
</body>
</html>
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP