--- id: 587d7db2367417b2b2512b8b title: Understand the Immediately Invoked Function Expression (IIFE) challengeType: 1 videoUrl: '' localeTitle: 理解立即调用的函数表达式(IIFE) --- ## Description
JavaScript中的一个常见模式是在声明函数后立即执行:
(function(){
console.log(“Chirp,chirp!”);
})(); //这是一个立即执行的匿名函数表达式
//输出“Chirp,chirp!”立即
请注意,该函数没有名称,也没有存储在变量中。函数表达式末尾的两个括号()会立即执行或调用它。此模式称为immediately invoked function expressionIIFE
## Instructions
重写函数makeNest并删除它的调用,所以它是一个匿名的immediately invoked function expressionIIFE )。
## Tests
```yml tests: - text: 该功能应该是匿名的。 testString: 'assert(/\(\s*?function\s*?\(\s*?\)\s*?{/.test(code), "The function should be anonymous.");' - text: 您的函数应在表达式的末尾加上括号以立即调用它。 testString: 'assert(/}\s*?\)\s*?\(\s*?\)/.test(code), "Your function should have parentheses at the end of the expression to call it immediately.");' ```
## Challenge Seed
```js function makeNest() { console.log("A cozy nest is ready"); } makeNest(); ```
## Solution
```js // solution required ```