javascript 中 with 的用法
来源:互联网 发布:sql注入漏洞的危害 编辑:程序博客网 时间:2024/05/20 06:40
举例说明
function students() { this.name = 'Jerry'; this.age = 18; this.score = function(yuwen,shuxue,waiyu) { return yuwen + shuxue + waiyu; } } stu = new students(); //一般的写法 stu.name = 'Jack'; stu.age = 28; console.log("name : " + stu.name + ", age: " + stu.age + ", score : " + stu.score(85,90,92)); //使用with后,就相当于作用域此对象了 with(stu) { name = 'tom'; age = 23; console.log("name : " + name + ", age: " + age + ", score : " + score(60,80,50)); }
<form onclick="return validForm(this);"> <input type="text" name="username" id="username"/> <input type="submit"/></form>
//验证个表单 //一般写的方式 function validForm1(formObj) { if(formObj.username.value == '') { console.log('username can not null.'); return false; } } //加入with后 function validForm(formObj) { with(formObj) { if(username.value == '') { console.log('username can not null.'); return false; } } }
0 0
- JavaScript中with的用法
- javascript中with的用法
- javascript 中 with 的用法
- javascript中with的用法
- javascript 中with用法
- javascript 中 with的用法:(简化语句)
- javascript with 的用法
- JavaScript中with/this用法
- JavaScript中eval()、with()和reduce()的用法
- JavaScript中eval()、with()和reduce()的用法
- JavaScript中with、this用法小结
- JavaScript中with、this用法小结
- javaScript中with函数用法实例分析
- sql 中with的用法
- js中with的用法
- js中with的用法
- SQL 中with的用法
- JS中with的用法
- 最近的学习
- 图中节点的度数
- HTML学习笔记之框架的应用
- 使用!访问到具体的method中,而不是直接在xml中设置
- 奇虎360 android 安全卫士 root核签名认证分析
- javascript 中 with 的用法
- Android Studio获取SHA1和MD5值的方法
- VS2010中利用CUDA对GPU进行直接开发
- ArcGIS教程:用点提取 (空间分析)
- 新的开始
- Java基础--异常
- 论程序员实现功能开发
- Django学习笔记(一)
- iOS音视频实时采集硬件编码