---
title: "函数名和函数付给一个变量的区别"
author: "digilover"
date: "2012-04-29T09:09:57Z"
tags: []
categories: ["Web前端"]
slug: "untitled"
draft: false
lastmod: "2012-04-28T15:23:40Z"
id: 1503480
url: "https://digilover.iteye.com/blog/1503480"
---

&lt;script type="text/javascript"&gt;

 function Person(){ }

 var person1 = new Person();

 person1.name="digi";

 person1.age=25;

 function sayFunc(){

 alert(person1.name+":"+person1.age);

 }

 person1.say = sayFunc;

//将方法名给person1的方法say，如果将函数赋值给say方法，那么person1.say()都不必调用就可弹出对话框，因函数赋给say方法，表示将函数执行结果给say方法，而sayFunc函数执行结果是弹出对话框。

 person1.say();

&lt;/script&gt;