請讓我知道如果問題是愚蠢的,而不是負責?Javascript的屬性
我剛剛開始使用javascript進行單元測試。我一直在執行this博客代碼到我的應用程序。我只是混淆了名稱參數被傳遞給JavaScript中的函數。如果我們談論的Java,PHP或任何其他語言,他們採取在構造函數參數和理解像
$vehicle = new Vehicle('argument here');
Class Vehicle {
protected $name;
function __construct($name) {
$this->name = $name; // we can use the property any where in the class
}
}
//Is name Property? Object? or anything else?
//javascript
(function(name) {
"use strict";
function vehicle(modal) {
this.modal = modal || 'Civic 2015';
}
name.vehicle = vehicle; //? ? ?
})(this);//also why using (this) ?
也是一個例子將受到極大的歡迎類的東西之內使用。
請在JavaScript中閱讀關於OOP的好教程。有一個可在[MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Introduction_to_Object-Oriented_JavaScript) –