Well I'd say Javascript only recently got proper lexical scoping with let before that you had global and function level and all the weirdness that brought about.
Plus prototypal inheritance is wonderful and it's a damn shame it confuses so many people.
...doesn't PHP have first class functions? I thought first-class functions meant you could use them as arguments or assign them to a variable, e.g.:
<?php$some_function_holding_var=function($inner_arg){echo"I'm a function saying $inner_arg!";};$some_function_holding_var("hello");// okay, not very random$random_array=[1,2,3,4];array_walk($random_array,function(&$number){++$number;});print_r($random_array);$pick_func_based_on_time=function($some_time){$even_function=function(){echo"even";};$odd_function=function(){echo"odd";};switch($some_time%2){case0:return$even_function;break;case1:return$odd_function;break;default:echo"I broke math...";break;}};$chosen_function=$pick_func_based_on_time(microtime(true));$chosen_function();
I'm honestly just curious as to if there's a meaning of first-class functions I'm missing. (And enjoyed the chance to do ridiculous code stuff.)
That's pretty much it. First class function means you can use functions wherever normal language primitives will go. It can be returned, used in expressions...
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Javascript:
Prototypal inheritance
Lexical scoping and closures.
The fact that you can construct almost any traditional design pattern with the above.
Closures and first class functions are also powerful instruments in functional javascript.
Also:
,,,;
Who is complaining about Lexical scoping? A bunch of Lisp diehards?
Lol. No one really. Just necessary to point out what's possible with Prototypal inheritance.
Well I'd say Javascript only recently got proper lexical scoping with
let
before that you had global and function level and all the weirdness that brought about.Plus prototypal inheritance is wonderful and it's a damn shame it confuses so many people.
Love first class functions. I miss that perhaps the most when programming in the other scripting language I use the most: PHP.
...doesn't PHP have first class functions? I thought first-class functions meant you could use them as arguments or assign them to a variable, e.g.:
I'm honestly just curious as to if there's a meaning of first-class functions I'm missing. (And enjoyed the chance to do ridiculous code stuff.)
That's pretty much it. First class function means you can use functions wherever normal language primitives will go. It can be returned, used in expressions...