I have this code in google tag manager:
<!-- Facebook Pixel Code -->
<script>
!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,
document,'script','https://connect.facebook.net/en_US/fbevents.js');
fbq('init', '***********');
fbq('set','agent','tmgoogletagmanager', '***********');
fbq('track', "PageView");
</script>
I just wondered if anyone could tell me what '!function' is, or what it does? I have never seen it before and a google/duckduckgo search produced no results, that I could see.
Could it mean 'not a function'? Weird!
The Set object lets you store unique values of any type, whether primitive values or object references. you are passing new object not reference so it is allowing to add duplicate.
The findDuplicates function (below) compares index of all items in array with index of first occurrence of same item. If indexes are not same returns it as duplicate. This doesn't return a unique array, duplicates will be included more than once if they're duplicated more than once in the array.
It's a shorter method of writing an IIFE:
!function(){console.log('foo')}()
Is 1 character shorter than:
(function(){console.log('foo')})()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With