W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<!DOCTYPE html> <html> <body> <p>如果指定的属性在指定的对象中,则 in 运算符返回 true。</p> <p id="demo"></p> <script> // 数组 var cars = ["Audi", "Volvo", "BMW"]; // 对象 var person = {firstName:"Bill", lastName:"Gates", age:19}; document.getElementById("demo").innerHTML = ("Audi" in cars) + "<br>" + (0 in cars) + "<br>" + (1 in cars) + "<br>" + (4 in cars) + "<br>" + ("length" in cars) + "<br>" + ("firstName" in person) + "<br>" + ("age" in person) + "<br>" + // Predefined objects ("PI" in Math) + "<br>" + ("NaN" in Number) + "<br>" + ("length" in String); </script> </body> </html>