Greasy Fork is available in English.

Discuții » Dezvoltare

How to use !function in javascript

§
Postat în: 15-02-2021

When I was trying to use !function It gave me false, Is there a way to use it?

§
Postat în: 15-02-2021
Editat în: 15-02-2021

To use what? If you don't know basics of the language you need to learn it here: https://javascript.info/ , not on the website for ready scripts.

§
Postat în: 16-02-2021
Editat în: 16-02-2021

!function in javascript is equal nothing, this doesn't exist

! means not...

function FunctionName() //Creates a variable named FunctionName
{ //Starts the function
var VariableName = true; //Creates a new variable with the value of true

if (VariableName !== false) //Check if the variable VariableName is NOT equal false
{ //Starts the function
alert('yes the variable VariableName is NOT equal true'); //If the variable VariableName is NOT equal false show a message
} //Finishes the if condition

} //Finishes the function

FunctionName(); //Executes the function....

§
Postat în: 16-02-2021

btw this doesn't do anything does it? https://greasyfork.org/en/scripts/421266-easy-cookie-manager

Please delete that script or make it unlisted...

wOxxOmMod
§
Postat în: 16-02-2021

@hacker09, it's a library so it's intended to be used by other scripts. Don't make hasty judgments.

wOxxOmMod
§
Postat în: 16-02-2021

@Jonas12, what you saw is a well-known method to make IIFE, see https://flaviocopes.com/javascript-iife/

§
Postat în: 16-02-2021

@wOxxOm

Ok.
He just showed 3 weird function syntaxes using unary operators, but didn't explain why they are weird and what makes them better or worse than arrow functions

wOxxOmMod
§
Postat în: 16-02-2021
Editat în: 16-02-2021

"Weird" because there's no reason to use those unary operators but some people may still want to just for fun or to make the minified output shorted by a few characters. Also, IIFE is not better or worse than an arrow function because it's not an alternative: you can use them together e.g. (() => { ....... })()

wOxxOmMod
§
Postat în: 16-02-2021

er, "shorted" -> "shorter"

§
Postat în: 27-02-2021
Editat în: 27-02-2021

@Konf Said

To use what? If you don't know basics of the language you need to learn it here: https://javascript.info/ , not on the website for ready scripts.

Did you see the title?

Postează un raspuns

Autentifică-te pentru a posta un răspuns.