JSFiddle - React, Tailwind, and code Playground

by camnpr

JavaScript

// 不要使用with
// With的使用方法如下,但有可以引起与局部变量名的冲突,例如name。

function Lakers() { 
    this.name = "kobe bryant"; 
    this.age = "28"; 
    this.gender = "boy"; 
} 

var people=new Lakers(); 
with(people) 
{ 
    var str = "姓名:" + name + "<br>"; 
    str += "年龄:" + age + "<br>"; 
    str += "性别:" + gender; 
    document.write(str); 
}