Answer the question
In order to leave comments, you need to log in
Logical negation of the result of executing an anonymous function
A sample of the following code was found in the facebook sorts. Please tell me the purpose and meaning of using such a technique: Original:
Thank you!
!function(){
…
}();
!function(){
var c = document.documentElement;
var b = 'child_focused';
var d = 'DOMControl_placeholder';
var a = function(e){
e = e || window.event;
var f = e.target || e.srcElement, h = f.getAttribute('placeholder');
if (h) {
var g = Parent.byClass(f, 'focus_target');
if ('focus' == e.type || 'focusin' == e.type) {
if (f.value == h) {
f.value = '';
CSS.removeClass(f, d);
g && CSS.addClass(g, b);
}
}
else
if (f.value == '') {
CSS.addClass(f, d);
f.value = h;
g && CSS.removeClass(g, b);
}
}
};
c.onfocusin = c.onfocusout = a;
if (c.addEventListener) {
c.addEventListener('focus', a, true);
c.addEventListener('blur', a, true);
}
}();
Answer the question
In order to leave comments, you need to log in
There's a meaning. If you do not write !, then the function will be recognized as a function declaration, and it cannot be called immediately, i.e.
function (){
/* body */
}()
(function (){
/* body */
})()
longer by 1 character.
!function(){}() without return returns true anyway.
And the meaning depends on the context in which this function is performed.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question