Pregunta de entrevista de Svitla Systems

Have I heard about are arrow functions?

Respuesta de la entrevista

Anónimo

14 abr 2025

I gave them my answer — “They’re inline functions used for making temporary logic work only where they’re needed, rather than defining them globally.” I also added that they can be used as closures, particularly when passed as parameters or callbacks. They’re short, concise, and useful for situations where you need a quick, temporary function without cluttering your global namespace. Then they asked me about using the variable itself in a var_dump — “What would happen if you dump the variable?” I answered that the var_dump wouldn’t display the return value of the arrow function, because the function isn’t executed until called, and var_dump is just showing the function definition at that point. It wouldn’t evaluate the function, just show the function’s structure. But, they weren’t happy with my answer. It seemed like they were looking for something more exact or more nuanced, even though I was explaining it correctly. I could tell that at this point, it wasn’t about having a meaningful conversation — it felt like they were focused on getting the “correct” answer, no matter how trivial the question was. I knew that arrow functions are useful, especially in small scopes, but at that point, it felt like they were digging into the details for the sake of it. It wasn’t really a practical problem to solve. And that was frustrating — at this stage, I was more focused on the real-world applications of PHP, not a theoretical quiz.