JavaScript Shorthand Tip: Arrow Functions | #shorts

preview_player
Показать описание
Hey everyone 😀 It's the third JavaScript Tip video that I published for you guys! I noticed that you're really into this type of shorts and also there are still so many tips like Arrow Functions I can share with you. Subscribe me and never miss another video 👇

🔔 Subscribe Now!

🎵 Music
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Track: Ikson - Anywhere [Official]
Music provided by Ikson®
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Thanks for watching, I appreciate it 🙏
Made with 💗 by Hossein
Рекомендации по теме
Комментарии
Автор

Template literals are easier..

const welcome = u => `Welcome ${u}`

brandonz
Автор

const welcome = user => `Welcome ${user}`

godlike code

kon
Автор

"kids code" is faster than "adults code" :p

mhm
Автор

To the people complaining about function being faster than arrow functions you’re talking about mere microseconds, and you’re sure as hell not running JavaScript programs on your grandfathers Commodore 64.

If you’re so obsessed with micromanaging performance, you‘ve already failed by using JavaScript, that’s what C is for. Arrow functions help declutter code, and I only write functions this way now.

mr.johnson
Автор

I used to use arrow functions, up until Web Dev Simplified said that normal function declarations get hooked all the way to the top of the code.
That just changed my mind to using regular functions. I did like the arrow function syntax, though.

theannoyingone
Автор

Functions with function keyword are good and easy to understand when they are written in main scope. Arrow functions are handy when you declare them inside callbacks or promise chains or so. Example:
function setUsersAsync() {
return fetch(‘/api/users’)
.then(res => res.json())
.then(users => setUsers(users))
.catch( console.error );
}

jamshediqbal
Автор

Well… there are time when you want to use the arrow function and there are times where you want to use the function keyword. When you use the function keyword, the function will be hoisted to the top of the file. If using the arrow function, it won’t get hoisted. Understanding how hoisting works is pretty important in JS.

Crispypoyo
Автор

It's not about how fancy your code looks, it needs to be readable and that is what is appreciated.

aurobindobhuyan
Автор

Your code don't have space between welcome and user.

prshendra
Автор

That reminds me some sh1тty mobile ads

_translt_
Автор

debatable. sometimes code that lets you know what it is, its better than shorter code
so, knowing that a variable is an actual function sometimes takes longer than something that already has the keyword "function" in it.
thats why html also have "footer", "nav", "section" etc instead of just using "div"s everywhere

juancamacho
Автор

I like the first version of writing more in terms of legibility and beauty.
P.S. I don't write to java.
I am a Python programmer.

DIMFLIX
Автор

Bruh understanding and applying Implicit returns does not make you a legend. I’d be fully employed by now if that was the case.

marvintoussaint
Автор

Incluso "Legends code" está incompleto, yo personalmente incluiría un operador ternario para retornar un valor alternativo en caso de que el parámetro "user" no sea considerado, de este modo la función siempre retornará algo, como un "try-catch"

Mike-jqos
Автор

legend code if your function only need one parameter, if it needs more than one you must close all parameters between brackets, and if your function has to do something more difficult that print one silly statement, you better use brackets

haroldpepete
Автор

When deciding the use case of the arrow function, it all boils down to the size of the program-

Fewer lines and words for more action!

It’s best for the arrow function to be used during the refactoring process when the code works and you want to make the code smaller!

Otherwise, stick to the basics in order to see the flow of your program when you come back!

TheRealAnsontp
Автор

Shorter not always simpler to read tbh. If you have more complex functions with more variables, your inline function is gonna be to long so it would be better to use common functions instead.

thegate
Автор

Not really lol, arrow functions has lexical scoping for the "this" keyword, sometimes you need normal functions for this (or use .bing(thisobject) with arrow fn

ananthdev
Автор

why to be so dumb
each method has pros and cons
nobody writes those "pure" functions
you would have a lot of nesting, with context binding, etc.
and sometimes simplicity is a key

no_bs_science
Автор

It's related to code matinatblity lots are wondering function is faster and all, I'll tell you one thing sometimes you need to see the structure of 10000 of lines codes as well above all there eventually converted into first one, it's better use what's comfortable to maintain and debugging, this improvemts you can, take better example tho..

darshanhegde