in的用法主要是用來判斷一個物件裡是不是有這個變數
例如下面程式碼,alert出yes
var car = new Object(); car.name = "Johnson"; car.color = "green"; car.number = "XXX-3333"; if("color" in car) alert("yes");
in的用法主要是用來判斷一個物件裡是不是有這個變數
例如下面程式碼,alert出yes
var car = new Object(); car.name = "Johnson"; car.color = "green"; car.number = "XXX-3333"; if("color" in car) alert("yes");