#100DaysOfWeb in Python Transcripts
Lecture: Common JS gotchas
0:06 was designed in 10 days.
0:10 Gary Bernhardt, in his inspiring talk
0:16 in relation to the time it took to design Closure
0:20 and you see it was very fast.
0:24 And that led to some weird decisions
0:27 in the design and here he shows some examples.
0:31 Go watch this talk.
0:33 It's not only highly entertaining, and inspiring
0:36 but also visionary 'cause a lot of what he said
0:39 five years ago is actually very relevant today.
0:49 Well, the most important thing
0:50 are global variables.
0:52 As per best programming practices
0:54 the less isolated something is the less reliable.
0:58 Make something global and it can change
1:01 in multiple locations.
1:03 We've already seen that
1:04 if you use the var keyword to initialize variables
1:08 those variables can easily be
1:10 clobbered in outer namespaces.
1:13 So you should use let and const.
1:20 but not its block scope.
1:22 No information hiding.
1:28 allows you to omit semi-colons
1:30 at the end of your statements.
1:32 Which usually is not a problem
1:34 unless you space your code in a certain way
1:37 then errors again pass silently.
1:40 So make sure you use semi-colons
1:43 to not run that risk.
1:47 And there are two equality operators.
1:49 If you use double equals sign
1:51 to compare number one and string one
1:55 it would say that they were equal.
1:57 But that might not be what you want
1:59 because although they look the same
2:02 they're not from the same data type.
2:04 So it's recommended to use triple quotes
2:07 which not only compares the values
2:10 but also the types.
2:11 So in that case
2:13 number one and string one would not be the same.
2:17 And, similarly there are two ways
2:19 to say that something is null, or undefined.
2:23 Where Python for example only has none
2:25 and it still confuses me
2:27 which one is used in which scenario.
2:31 Remember, errors should never pass silently
2:34 according to Python, unless explicitly silenced.
2:38 There should be one, and preferably only one
2:41 obvious way to do things.
2:42 And namespaces are one honking great idea.
2:48 It's not Python.
2:49 But looking at the inner works
2:58 is dynamic and easy to get started with.
3:01 It's just that you have to keep
3:03 these kinds of gotchas in mind
3:07 to rule out any unnecessary risks.
3:10 And this is a very high level
3:13 And in the last video, I'm going to
3:15 point you to some resources
3:20 Because again, it's used everywhere
3:24 So any time you can invest learning this language
3:28 is time well spent.