Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在 PHP 中,我们这样做:
function($param) { $this->{$param}; }
我们如何在 JavaScript 中做到这一点?
我不了解 PHP,但您可以使用方括号表示法来访问属性。
function(param) { this[param]; }
在javascript中你可以这样写
function House(rooms,price,garage) { this.rooms=rooms; this.price=price; this.garage=garage; }