Javascript Lesson 1

[)roi(]

Executive Member
Joined
Apr 15, 2005
Messages
6,282
Let's start with variable assignment...
Javascript is so easy and you can trust the results.

Javascript Lesson 1.jpg
:sick:
 

rrh

Expert Member
Joined
Nov 29, 2005
Messages
4,031
Your 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)
 

Hamster

Resident Rodent
Joined
Aug 22, 2006
Messages
42,928
Your 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)
According to that pic five.wtf loses its value after the increment.... a tiny bit wtf
 

[)roi(]

Executive Member
Joined
Apr 15, 2005
Messages
6,282
Your 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.wtf
The premise of TDD, XP and FP is driving consistency, difficult when the language is fundamentally flawed.
 
Last edited:

[)roi(]

Executive Member
Joined
Apr 15, 2005
Messages
6,282
It's a consequence of 10 days design : https://www.computer.org/csdl/mags/co/2012/02/mco2012020007.html

Javascript is often referred to as the most hated language and the one everyone just wish would go away; problem is finding a replacement that everyone will accept; Google tried Dart, uuuhhh! Yeah they weren't really committed, especially if you consider Google also made Go, surely the Go team could have built something special.

Everybody else just has higher priorities elsewhere so Javascript remains, not because of any brilliance, but simply because nobody could be bother at this time to lead a project for its replacement; there is no profit in replacing Javascript...
 

eternaloptimist

Well-Known Member
Joined
Jul 10, 2013
Messages
175
[video=youtube;JxAXlJEmNMg]https://www.youtube.com/watch?v=JxAXlJEmNMg[/video]
whole series is amazing!
 

[)roi(]

Executive Member
Joined
Apr 15, 2005
Messages
6,282
yeah but it's slow way to get to the back story of Javascript re a lot is a back story to programming
Here's a quick summary from Brendan Eich:
[video]https://m.youtube.com/watch?v=NJxB0Pp69IQ[/video]
 
Last edited:

_kabal_

Executive Member
Joined
Oct 24, 2005
Messages
5,923
the 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
 

[)roi(]

Executive Member
Joined
Apr 15, 2005
Messages
6,282

Necropolis

Executive Member
Joined
Feb 26, 2007
Messages
8,401
Not a huge fan on JS - I'll use it if I have to - but I prefer not to.
 

[)roi(]

Executive Member
Joined
Apr 15, 2005
Messages
6,282
WHY JAVASCRIPT DEVELOPMENT IS CRAZY?

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.........

http://www.planningforaliens.com/blog/2016/04/11/why-js-development-is-crazy/
 

[)roi(]

Executive Member
Joined
Apr 15, 2005
Messages
6,282
Javascript Test

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 index values.
 
Last edited:

C4Cat

Honorary Master
Joined
Nov 9, 2015
Messages
14,307
[)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.

Makes sense once you know why, but it's unintuitive.
 

[)roi(]

Executive Member
Joined
Apr 15, 2005
Messages
6,282
Makes sense once you know why, but it's unintuitive.
Exactly; Javascript is weird, but a lot of the weird parts could be understandable if they simply implemented better lexical analysis.

Well in truth I'd prefer this just fail: "insufficient parameter values provided"
 
Last edited:
Top