---
title: "with() 语句"
author: "wgcode"
date: "2011-06-22T18:31:52Z"
tags: []
categories: ["编程语言"]
slug: "with"
draft: false
lastmod: "2011-06-22T18:31:52Z"
id: 1101408
url: "https://tts.iteye.com/blog/1101408"
---

今天看到了这样的语句：  
    with(条件) {  
       语句;  
       ...  
     ｝  
以前没见过，有点奇怪。搜索中文居然没有解答，看来这个语句是相当基础了，可惜我真是不知，汗|||  
用英文搜索找到了，原来这个语句可以帮助我们call一个对象一次，多次访问它的属性和方法。  
例如：  
theContent\_txt.text = "the business is mine";  
theContent\_txt.\_x = 456;  
theContent\_txt.\_y = 345;

可以写为：

with(theContent\_txt)

{

text = "the business is mine!";

\_x =456;

\_y =345;

}