Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[js] 第235天 请写出几种匿名自执行的写法(至少三种) #1614

Open
haizhilin2013 opened this issue Dec 6, 2019 · 4 comments
Labels
js JavaScript

Comments

@haizhilin2013
Copy link
Collaborator

第235天 请写出几种匿名自执行的写法(至少三种)

我也要出题

@haizhilin2013 haizhilin2013 added the js JavaScript label Dec 6, 2019
@cxwht
Copy link

cxwht commented Dec 6, 2019

+function() {
}()
-function() {
}()
~function(){
}()
!function(){
}()
~~function(){
}()
!!function(){
}()

正好是昨天看到的

@bozaigao
Copy link

bozaigao commented Sep 26, 2020

(function () { console.log('自执行函数1'); })();
(function () { console.log('自执行函数2'); }());
!function () { console.log('自执行函数3'); }();
+ function () {
    console.log('自执行函数4');
}();
- function () {
    console.log('自执行函数5');
}();
~function () {
    console.log('自执行函数6');
}();
!function () {
    console.log('自执行函数7');
}();
~~function () {
    console.log('自执行函数8');
}();
!!function () {
    console.log('自执行函数9');
}();

@cai1994214
Copy link

只要前面是表达式就可以自执行
false || function(){console.log(1)}();
0,function(){console.log(1)}();
1*function(){console.log(1)}();

@xiaoqiangz
Copy link

(function(){
console.log(111)
}())
+function() {
console.log(222)
}()
-function() {
console.log(333)
}()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
js JavaScript
Projects
None yet
Development

No branches or pull requests

5 participants