标签:
var eatFunction = function (what_to_eat) { var sentence = ‘I am going to eat a ‘ + what_to_eat; console.log( sentence ); }; eatFunction( ‘sandwich‘ ); // is the same as (function (what_to_eat) { var sentence = ‘I am going to eat a ‘ + what_to_eat; console.log(sentence); })(‘sandwich‘); // is the same as (function (what_to_eat) { var sentence = ‘I am going to eat a ‘ + what_to_eat; console.log(sentence); }(‘sandwich‘)); // Three of them output ‘I am going to eat a sandwich‘
唯一的区别是,变量 eatFunction 被移除了,使用一对括号把函数定义包了起来。
标签:
原文地址:http://www.cnblogs.com/nodejsxxh/p/4421137.html