---
title: "javascript自定义对象"
author: "wanglihu"
date: "2011-12-21T08:35:09Z"
tags: []
categories: ["Web前端"]
slug: "javascript"
draft: false
lastmod: "2011-12-20T17:28:31Z"
id: 1318435
url: "https://wanglihu.iteye.com/blog/1318435"
---

实例：

&lt;script type="text/javascript"&gt;  
function person(name,sex){  
this.name = name;  
this.sex = sex;  
this.print = print;  
}  
function print(){  
var str = "name = " + this.name + ",sex = " + this.sex;  
document.write(str+"&lt;br&gt;");  
}  
var person = new person("wlh","man");  
person.print();  
&lt;/script&gt;

结果：

name = wlh,sex = man