码迷,mamicode.com
首页 > 编程语言 > 详细

JavaScript with

时间:2014-09-26 18:09:28      阅读:214      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   io   java   ar   sp   div   cti   

function Animal() {
    this.name = ‘xxx‘;
    this.id = 1;
}

var animal = new Animal();
with(animal) {  // 括号内可以不用 ‘对象.属性‘,直接用属性名或方法
    alert(name);
    alert(id);
}

 

JavaScript with

标签:style   blog   color   io   java   ar   sp   div   cti   

原文地址:http://www.cnblogs.com/shouwangzhe-/p/3994852.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!