Questions tagged [arrow-functions]

Questions about the compact function syntax in ECMAScript2015 (ES6) called "arrow functions" because of their use of "=>".

Filter by
Sorted by
Tagged with
-2 votes
1 answer
40 views

For each object in array, how to resolve promises that retrieve DB data and populate dropdown in sequential order?

I have an array of objects called projects. Each project has a project_id. I need to retrieve all members assigned to a project from the DB using the project_id, check if each member is approved, and ...
benevolentBanana135's user avatar
0 votes
1 answer
31 views

How do I go about removing an event handler created in an arrow function so that when the score limit for my game is reached, the buttons stop working

Like the title says, I want to have the buttons stop adding score and updating the player/cpu choices on the page. But I can't seem to figure out how to have that happen. Everything I've tried so far ...
Moonchkin's user avatar
0 votes
3 answers
73 views

Arrow function as a parameter to a function in JavaScript

I'm a beginner/intermediate JavaScript programmer and recently got a couple of exercises handed out on job interviews. I have to write a function in JavaScript called find that takes two parameters, ...
Ajedama's user avatar
0 votes
1 answer
51 views

Understanding Arrow Function Behavior with Conditional Operations in JavaScript

I'm learning arrow functions in JavaScript and attempting to conditionally set the value of show to false based on a certain value. While using the '&&' operator for this purpose, I ...
karthiK's user avatar
  • 17
2 votes
0 answers
79 views

Arrow function in class nextjs generate "use server" error

I'm implementing mobx in a nextjs app and when I created a class and tried to use it in a component I got the following error: Error: Functions cannot be passed directly to Client Components unless ...
Martin Gainza Koulaksezian's user avatar
0 votes
2 answers
87 views

What's the this value in callback arrow functions? [duplicate]

So as I am reading on the execution context in javascript and how does it works, everything seemed fine until I tried some examples on the this value of callback arrow functions. const printCard = ...
Abdullah Binsaad's user avatar
0 votes
0 answers
41 views

Creating a Parquet Folder from a very large CSV with R

I am trying to work with a 200GB csv using R. I'm exploring the arrow package and have been able to using the open_dataset() function to point to the file. arrow_data <- open_dataset( sources = ...
Terryb's user avatar
  • 51
0 votes
0 answers
10 views

this keyword is outputing different outputs in same object why? [duplicate]

i learned that this keyword inside an object method this refers to the object it self but when it tried it not why, when i tried that in arrow function syntax this keyword referred to the object it ...
Moayad344's user avatar
-1 votes
1 answer
24 views

Title: JavaScript this behavior inside an arrow function used in Object.defineProperty [duplicate]

Question: I'm encountering unexpected behavior when using an arrow function as a getter in Object.defineProperty in JavaScript. Here's my code: "use strict"; const obj = { a: 10, }; ...
Kübra Aksu's user avatar
0 votes
1 answer
21 views

Error : Expected to return a value at the end of arrow function

Expected to return a value at the end of arrow function , this is a common problem one can face easily while using react JSX in strict mode contentType = id => { console.log('') if (id === '...
Avik Biswas's user avatar
0 votes
0 answers
44 views

Typescript arrow function object with new key won't give any errors

In my typescript code I'm not getting any errors when I use the new keyword to create an Arrow function object. now i know according to the documentation, You can not use new keyword to create an ...
Lasitha Lakmal's user avatar
0 votes
1 answer
126 views

Arrow functions, methods and bind. Memory usage and performance

Please check the code below, I'm not sure if my JS is correct, I usually use TS. My question is: What is the difference in memory usage and performance in these two usages? Memory: As I understand ...
Vladimir's user avatar
  • 361
0 votes
0 answers
21 views

Access global this in Arrow function [duplicate]

I have two functions. One is normal function and one is arrow function inside an object. Inside the arrow function I want to access the inner Name and global name. const name = "globalname"; const ...
Saurabh Mahajan's user avatar
0 votes
0 answers
34 views

Error reading decimal datatype from Apache Arrow Parquet CPP library version 11.0.0

I am trying to read a parquet file and store it in custom C structure to further use in my C code case arrow::Type::DECIMAL: { const arrow::Decimal128Type* decimal_type = static_cast<const ...
Anamika Ahmed's user avatar
0 votes
2 answers
71 views

What's the correct way to declare event handler in class of JavaScript? [duplicate]

As I checked on MDN, method of a class looks like this: class Foo { method1 (){ // content of method1 } } However I found it's not good for event handlers <!doctype html> <html ...
Byzod's user avatar
  • 466
0 votes
0 answers
26 views

Difference between arrow function and variable = function(){} [duplicate]

I am beginner in JavaScript and I have a question. What is the difference between these two functions. const one = function(n){ console.log(n) and this arrow function. const one = (n) => { ...
Yash's user avatar
  • 1
0 votes
1 answer
35 views

Arrow function this behaviour [duplicate]

Example 1 const obj = { perimeter: () => { console.log(this); // this points to window } } obj.perimeter() const obj = { sing(){ console.log(this); const b = () =>{ ...
Indrajeet's user avatar
-2 votes
2 answers
120 views

How do I pass in parameters into arrow functions in react?

code I want the "elem" parameter of my component to be another component based on the boolean that is passed into my arrow function. I have tried passing in "mobile" as a parameter ...
Silverfang890's user avatar
0 votes
2 answers
60 views

What's the meaning of "=>" when not calling a function?

I'm learning JavaScript through freeCodeCamp and the way they explained (or rather, didn't) arrow functions has led to some massive confusion for me. I am familiar with calling a function using arrow ...
szymonhimself's user avatar
2 votes
0 answers
190 views

Why does JavaScript code usually use lambdas instead of named functions? [closed]

I'm getting started with JavaScript after a lot of experience with Python and some with C. I've noticed in a few tutorials that there seems to be a strong preference among JavaScript programmers to ...
Matthias Fripp's user avatar
0 votes
1 answer
29 views

How to change return type based on optional object parameter

How to create { a: boolean } only if aX exist in the obj parameter type IObjFunc = () => void interface IObj { aX?: IObjFunc bX?: IObjFunc cX?: IObjFunc } interface IReturnData { ...
kennarddh's user avatar
  • 2,309
0 votes
2 answers
65 views

Arrow functions behaviour inside promises

Q1.) Why I am getting undefined if i pass console.log in then block in a promise chian? new Promise((resolve, reject) => { console.log(4) resolve(5) console.log(6) }).then(() => console....
SHOBHIT GARG's user avatar
0 votes
0 answers
31 views

Describe, It, Before, After, Arrow Functions, unnamed functions and "this", utility or futility? [duplicate]

We are currently updating our linting to match the Front End Developers' idea of linting. Mostly because they want to be able to look at and understand our testing code. We are all working in ...
user3583204's user avatar
0 votes
2 answers
117 views

Why are arrow methods not allowed in Typescript?

The suggestions to allow arrow methods in Typescript have been rejected on the basis on "changing Javascript as language". How would it exactly change the language to have one less character ...
Anton Duzenko's user avatar
0 votes
3 answers
58 views

Confusion on inferred return type

I was working with Typescript and got confused with how the compiler infers the return types differently for these two functions. //this is of type () => boolean | "" const isFormValid = (...
snippetkid's user avatar
1 vote
1 answer
119 views

"Missing semicolon expected" while tying to run a cypress script [closed]

I am trying to add .each syntax but am getting the error "; missing" or "semicolon expected" also am working on cypress as there is no ; Test code: cy.get('.products').find('....
ahmed mahmoud's user avatar
0 votes
0 answers
61 views

<Function> is not a function, typescript even though it is a function

This is what my code looks like CheckForFunctionality.ts import {customFunctionA, customFunctionB} from './utilFunctions.ts' // both customFunctionA and customFunctionB are defined as arrow functions ...
kolman's user avatar
  • 350
0 votes
0 answers
59 views

What is the difference between returning an arrow function vs function declaration in Debounce? [duplicate]

While learning about Debounce in JS, I've seen 2 different approaches. Is there a difference between calling the callback within the function declaration example vs calling with apply binding within ...
Brandi's user avatar
  • 161
-2 votes
1 answer
36 views

Why do I keep getting this error every time? ReferenceError: Can't find variable: greet

This is the simple practice code const greet = (person) => { return `Hey ${person}!`; } When I call greet, it keeps bringing the above error. This also applies to almost all the code I write ...
josephine omondi's user avatar
0 votes
1 answer
57 views

React / Javascript : Why i cannot access the key "target" in the body of an arrow function?

I am newbie to Javascript / React and i am doing bit of development using React Functional Component. Let start off by showing you the sample code below. import React from 'react'; function App() { ...
yapkm01's user avatar
  • 3,630
0 votes
1 answer
76 views

Error: Invalid hook call on tRPC and Mantine CSS Custom hook

I'm having a Unhandled Runtime Error on Next.js. Calling an arrow function with void type was not a problem. I made it before implementing useForm hook on Mantine CSS library. Unhandled Runtime Error ...
circular_reference's user avatar
0 votes
1 answer
69 views

'this' implicitly has type 'any' because it does not have a type annotation (TypeScript)

I have a file .ts and get this error for the following code: const hulk={ nombre:'Hulk', smash(){ setTimeout(function(){ console.log(`${ this.nombre} smash!`); //HERE ...
Samantha Márquez's user avatar
0 votes
0 answers
72 views

Anonymous arrow function with anonymous object in razor component

I have a razor page. and I want to add an external javascript, this javascript uses an anonymous object as param and is an anonymous arrow function (if I not wrong) ()=>{......}(); if I set this ...
acmesoft's user avatar
-1 votes
1 answer
76 views

Hello, I created a function that finds the max of three numbers using arrow function in JavaScript. Is the code ok?

I tried using if-else statements inside the arrow function and it runs fine. I was wondering if it the code was correct. const fu= (x,y,z) => { if(x>y){ if(x>z)return x; ...
ApZa's user avatar
  • 1
0 votes
0 answers
25 views

typescript not recognizing arrowfunction type in object

Im currently working on a typesafe way of declaring an interface that declares how a function should return an object. This object should always contain the same functions. The interface is declared ...
Lucky's user avatar
  • 21
1 vote
1 answer
645 views

Is there a native S3 filesystem implementation for Apache Arrow Java?

I'm working with Apache Arrow in Java and I want to know if there is an implementation in the java library that provides a native S3 filesystem implementation like the one provided in the Python ...
Arjun Kashyap's user avatar
-2 votes
1 answer
191 views

How to return lowercase text in a javascript arrow function without using a return in the statement body [duplicate]

I am solving a problem for school. The problem instructs me to: "create and arrow function with the following: accepts a parameter does not use the return keyword returns text passed to it as ...
Sam Rose's user avatar
0 votes
0 answers
68 views

Custom Element / Web Component Methods as Arrow Functions [duplicate]

I'm learning about custom elements / web components, and was not sure why my connectedCallback() and attributeChangedCallback() methods never seemed to get called and did not receive any errors, but ...
David Mays's user avatar
0 votes
1 answer
298 views

Infinite loop when using setState in an arrow function in an onClick - Next 13

When I try to set a state by using an onClick I get an infinite loop. My component 'use client' import { use, useState } from "react"; import { gql } from "@apollo/client"; import ...
Douwe Pausma's user avatar
0 votes
2 answers
105 views

How to display the return value of my arrow function

I have an arrow function used to change the value of a sentence based on some conditions. When I log the result in the console, I obtain what it expected to be returned. But when I want to display ...
Cucumberbatch's user avatar
0 votes
1 answer
134 views

Read Date Time in C++ Code from parquet files

I am reading a parquet file in a c++ program on windows platform. The .parquet file has a column as "timestamp" and the data is like "2021-04-06 16:48:04.614365+00:00". Presently I ...
RKum's user avatar
  • 770
-1 votes
2 answers
94 views

"Invalid hook call." when trying to use useState in an arrow function

Hello fellow StackOverflow community : I'm encountering this issue, where my react-native app with TailwindCSS and TypeScript is returning me- Invalid hook call. Hooks can only be called inside of the ...
Gregory Buffard's user avatar
1 vote
0 answers
44 views

What is the difference between these two interface declarations? [duplicate]

What is the difference between these two interface declarations : interface A { foo: (x: number) => number; } const a: A = { foo: (x: number) => (x + 1); } interface B { foo(x: number): ...
souyahia's user avatar
  • 220
0 votes
1 answer
64 views

Destructuring hybrid array-objects returned by String.matchAll [duplicate]

String.matchAll yields hybrid arrays with added properties - index, input, and groups. E.g. [...'abc'.matchAll(/a|b|c/g)] yields: 0: ['a', index: 0, input: 'abc', groups: undefined] 1: ['b', index: 1,...
Kostya Hmelnitski's user avatar
1 vote
1 answer
62 views

Re-declaring arrow function [duplicate]

tried to re-declare an arrow function-- (Check code) Why is it giving error when var can be redeclared. I made an arrow function using var then tried re-declaring it using let as var can be ...
leo_00's user avatar
  • 13
1 vote
1 answer
81 views

Does Arrow Functions in JS also inherit the Function() prototype?

Given the risk of prototype-pollution in JavaScript, In case I can't freeze/seal the built-in Function()'s prototype, or some of it's parents in the prototype-chain (eg Object()'s), can I use arrow-...
Cocktail's user avatar
0 votes
1 answer
353 views

JavaScript: Conditionally process fetch response

I have a fetch() request returning a Response object that is either a zip file (blob) or a JSON if there was an error with the request. The code I have successfully processes the zip file and sends it ...
kfly2fly's user avatar
0 votes
2 answers
78 views

Assign characters to arrow pointer in c

struct room { char venue[15]; //variable } *stream; . . . void idealounge(){ int i,idealounge[10]; char room1[10]="MMLC"; *** ** stream->...
G Dydy's user avatar
  • 13
0 votes
0 answers
60 views

Logic behind setTimeout() function in javascript [duplicate]

This question is not about fixing a code,as I managed to do it, but to understand why it's happening. The idea was to delay a pop-up window (with 2 buttons and 1 input text). Initially I used version-...
EscFox's user avatar
  • 23
0 votes
3 answers
29 views

It's working diffently in react while using and not using braces in arrow function

this is another geek here. I am learning reactjs now. I found this in my code while I was tring to create a Button element for my app. My idea is to decide background color according to a prop called ...
shark_feeder's user avatar

1
2 3 4 5
31