Arrow function failed #javascript #shorts #programming #coding #codinglife #coding

preview_player
Показать описание

Рекомендации по теме
Комментарии
Автор

It says clearly in the javascript documentation that "The  arguments object is a local variable available within all non-arrow functions."  so its not wierd that it does not work for you.

AndrewTSq
Автор

It's not literally a fail, arrow functions don't have scoped variables like *this*, *arguments* and *callee*, this is intentional (Instead it gets the scope from where it was declared, if it is declared in the global scope then everything will be coming from globalThis, if it is inside a function it will access these function variables). As for getting the list of arguments this is easy, no one else uses *arguments* when you can do the same thing with rest operator

const fn1 = (...arguments) => {
console.log(arguments);
}

hadawardgz
Автор

Don’t use arrow functions in classes as they are not bound to the class but to the scope where the class is defined

NoOne-evjn
Автор

It literally doesn’t matter shit since there are not really many use cases of using the arguments array by itself. I know people that have worked with JavaScript for years andnever encountered it being used in production ever.

Simon-yffo
Автор

hi @bitfumes we can use rest parameters to get the arguments.in the fat arrow functions 👍🥳😂

daveraj
Автор

Try use IIFE (immediate invoked function execution)

fredianriko
Автор

Object literal declaration with arrow functions is bad idea. obj = { method: ()=>this}

ЮрійАндрашко-уя
Автор

If u wanna call a function it's not declared before, Js doesn't put then in the top in the run time

xtz_
Автор

When you use this keyword in function scope, arrow function give global this and the normal function give it's own this value.... I hope i define well 🤩😜😍

its_code
Автор

we should not use arrow functions in class constructor

satadeepdasgupta
Автор

but sometimes regular function is also not working when we scope it and use callback function and use "this".
const food = {
recipes: [ "potato", "oil", "tomato"],
cook: function(delay = 1000) { setTimeout(function(){ console.log(this.recipes.join(", "));
}, delay);
}
};
food.cook(); // uncaught TypeError: cannot read propperty 'join' of undefined.

RyoCodes
Автор

It's not useful when there's 'this' keyword to be used in the function statement

blackpurple
Автор

People still use the arguments variable in 2022?

JJordy
Автор

You can't use it as a constructor I think

daliovic
Автор

we cant use it with this keyword also by the way this video was really good

abdulwajidafridi
join shbcf.ru