WifiConfiguration wifiConfig = new WifiConfiguration();
wifiConfig.SSID = String.format("\"%s\"", ssid);
wifiConfig.preSharedKey = String.format("\"%s\"", key);
WifiManager wifiManager = (WifiManager)getSystemService(WIFI_SERVICE);
//remember id
int netId = wifiManager.addNetwork(wifiConfig);
wifiManager.disconnect();
wifiManager.enableNetwork(netId, true);
wifiManager.reconnect();
如果我运行该代码var myCar2 = {
maxSpeed: 70,
driver: "Arnold",
drive: function(speed, time) {
console.log("speed " + (speed * time));
},
logbook: function(a , b) {
console.log("max speed " + this.maxSpeed + " " + this.drive(a , b));
}
};
myCar2.logbook(3 , 6);
是this.drive(a , b)
。如何使用undefined
将变量传递给drive()
函数?
答案 0 :(得分:7)
您正在将变量传递给驱动器,并在其中定义它们。如果它们不是那么你不会在输出中得到速度18 ,你会得到速度NaN 。
undefined
值是drive
的返回值,这是因为您没有在该函数中放置return
语句。