我一直在關注從www.w3school.com的javascript教程,並在閱讀中我已經在我的腦海裏有一個問題一個例子,代碼如下:關於字符串的constructor屬性混淆
<html>
<body>
<script type="text/javascript">
var txt =new String ("Hello World!");
document.write(txt.constructor);
</script>
</body>
</html>
現在,在這個代碼的響應IAM得到的是:
function String() { [native code] }
但是,根據我的構造函數必須在它有一個參數有點像這樣:
function string(value){}
任何人都可以請告訴我爲什麼它返回沒有參數的構造函數。
在js參數中是隱含的https://developer.mozilla.org/zh/JavaScript/Reference/Functions_and_function_scope/arguments – clyfe 2012-01-03 09:57:59