---
description: >-
  https://stackoverflow.com/questions/9267289/what-does-function-in-javascript-mean
---

# what does !function in Javascript mean? (ok)

41

It is short-hand or alternative of [self-invoking anonymous function](http://sarfraznawaz.wordpress.com/2012/01/26/javascript-self-invoking-functions/):

```
(function(){
  // code
})();
```

Can be written:

```
!function(){
  // code
}();
```

You can also use `+` instead of `!`.

If you simply did:

```
function(){
  // code
}();
```

That will create problems, that's why you need to add `!` before it which turns the _**function declaration**_ into _**function expression**_.

Đọc thêm bài này: [https://app.gitbook.com/@javascriptuse/s/advanced/javascript-self-invoking-functions-ok](https://app.gitbook.com/@javascriptuse/s/advanced/javascript-self-invoking-functions-ok)
