RUVIDEO
Поделитесь видео 🙏

Anonymous Function Call in javascript | Function Expression using Negation & More

In this tutorial we are looking into javaScript function calls, focusing on anonymous function calls in JavaScript. We delve into function expressions using negation, a technique marked by an exclamation point (!) preceding the function in JavaScript. Discover the effects of the exclamation mark before a function, its purpose, and when best to utilize this unique technique.

Have you used function starting with exclamation mark or function expression using logical not operator? What does the exclamation mark do before the function? What is Javascript anonymous function call? Why use NOT operator on anonymous function call? what does !function in javascript mean? What is ! preceding function in javascript?

In this video we will answer following questions:
- In JavaScript, what is the advantage of !function(){}() over (function () {})()
- How exactly does !function(){}() work
- JavaScript !function(){}
- What is the purpose of declaring a function like !function(){ code }()

Learn what is anonymous function and what is named function, what is immediately invoked function expression and what is difference between a function and function expression in javascript. Learn about function expression using negation in javascript.

A function is a block of code defined once and called multiple times later. In JavaScript, a function can be declared in many ways.

for example:
function sayHello(){}
This is a function declaration. But it is not invoked yet. We would need an invocation, to actually run the function.

sayHello()

will run this function.
This is a function call.
It is undefined.
This is a named function that is being executed.
We can declare a function like this and invoke it later in code.

What if we need a function that invokes immediately after its being declared.
In this case we don't need name for this function.
If we remove name from this function.
It throws SyntaxError.

To fix this we can turn it into a function expression and use IIFE.
IIFE is an 'Immediately Invoked Function Expression'.

(function(){})()

It is a function expression that is being invoked immediately. It shows undefined at declaration point. An immediately invoked function expression (IIFE) doesn’t explicitly return anything, so its return value is undefined.

BTW we can also use arrow in IIFE.

There is another way to declare and invoke a function. It is by using the logical NOT ( ! ) operator or negation.

!function(){}()

By using this syntax, we have removed parenthesis and we are saving one byte per function expression.

NOT operator, alone can not invoke the function. We still need parenthesis at the end. Parenthesis has higher precedence than exclamation sign and it instantly calls the function.

Removing NOT operator will end up in SyntaxError, because you can't put arguments right after a function declaration. NOT operator makes the expression return a boolean, based on the return value of the function. IIFE doesn’t explicitly return anything, so its return value will be undefined, which leaves us with !undefined which is true.

And why this is used. This is usually done by minification or uglification scripts, where every single byte counts.

So if you see such function. It is just a function expression using logical NOT operator.

✅ How To Hide / Protect JavaScript Code - Techniques and Tools
https://youtu.be/8VyzRlxo2-k
✅ React JS UNDEFINED Solution | Reactjs Learning | Learn ReactJS & JavaScript Debugging Fast
https://youtu.be/0IvxCxcEBPo
✅ Calculate Sum or Total from Values in Array & Array Object | Learn JavaScript | Reduce Method
https://youtu.be/Xw7G2b80dDg
✅ Get URL Parameters in JavaScript | URLSearchParams
https://youtu.be/CZP1iQFQjEY
✅ DIV to PDF, Iframe to PDF using JavaScript Only (with CSS & Images Support)
https://youtu.be/DV2tAG5E-F0
✅ How To UnMinify JavaScript Minified Files Easily | Decrypt Complex JavaScript Code
https://youtu.be/uh8_Rt4Qam8
✅ Toggle Class in Vanilla JavaScript | Learn JavaScript
https://youtu.be/IdtwowBlfmI
✅ How to Execute a JavaScript File by using NPM
https://youtu.be/2xcoenAdSWs
✅ Get User's Location (Country, State, City) with Free Unlimited API Access | PHP & JavaScript
https://youtu.be/_P8_JUaoNgs
✅ Replace jQuery with Vanilla JavaScript Code Easily | jQuery vs JavaScript
https://youtu.be/toJ3vRUMf2g
✅ Toggle in Vanilla JavaScript
https://youtu.be/ebDCyf-JFOw
✅ JavaScript Variable Redeclare & Reassign | VAR vs LET vs CONST | Practical Examples
https://youtu.be/9NNva3x0awQ

Thank You!
? LIKE VIDEO
? SUBSCRIBE
? PRESS BELL ICON
✍️ COMMENT

⚡Channel: https://www.youtube.com/webstylepress
⚡Website: https://www.webstylepress.com
⚡FaceBook: https://www.facebook.com/webstylepress
⚡Twitter: https://twitter.com/webstylepress
⚡GitHub: https://github.com/webstylepress
#function #functionExpression #IIFE #logicaloperator #logicalNOTOperator #NOTOperator #js #javascript #WebStylePress #WebDevelopment

Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «Anonymous Function Call in javascript | Function Expression using Negation & More», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.

Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.

Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!

Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.