According to that pic five.wtf loses its value after the increment.... a tiny bit wtfYour problem being ?
"five++" (postfix increment) will return the current value of the variable (i.e. 5) then increment the variable by one (i.e. value now 6)
JS is littered with inconsistencies; e.g. five.wtfYour problem being ?
"five++" (postfix increment) will return the current value of the variable (i.e. 5) then increment the variable by one (i.e. value now 6)
Perfect example of javascript's insensibility; it's a numbered acid trip to planet NaNthe weird thing is that when using "call" the parameter is wrapped in some sort of context so that it can be refered to as "this"
it is like it makes an object that has a standalone value, like a primitive, but also behaves like an object
https://jsbin.com/noqinurapo/edit?js,console
Web development is fun! Javascript is … daunting.
Everything else in web development clicks for you, but when you dig into Javascript it’s like you’re missing some big, foundational piece of knowledge that everyone else has that would help you make sense of it all.
The truth is, yes, you’re missing a few pieces to the puzzle.
But also, the current state of the art in frontend development is actually crazy.
It’s not just you.
Sit down, pull up a chair.
It’s time to write a Javascript application.........
var result = ['10', '10', '10', '10'].map(parseInt);
[)roi(];17492650 said:What is the value of result after this command?
Code:var result = ['10', '10', '10', '10'].map(parseInt);
Note: No cheating, you should answer off the cuff... based solely on your experience with using functional programming and/or Javascript.
Ps... it's not what you think it should be; +100 points if you can explain why?
Here's the answer, weird right?
...and here's a solution with an explanation of why it's happening.
The conclusion is Javascript's lexical analysis sucks; plus in most FP languages only tuples are substituted for parameters i.e. not subsequent array values.
Exactly; Javascript is weird, but a lot of the weird parts could be understandable if they simply implemented better lexical analysis.Makes sense once you know why, but it's unintuitive.