JavaScript Variables and Types for Pythonistas (Summary)

Congratulations, you made it to the end of the course! Kestrel Print’s backup check now runs in JavaScript. On the new server, where nobody set BACKUP_BUCKET, backup-check.js refuses to start and exits with status 1, as the Python check does, instead of backing up to a bucket called undefined.

With the warning and the debug line added, it prints the same lines as the Python check in all three runs, except that the debug line reports the bucket’s type as string where Python says str.

In this course, you learned how to:

  • Declare each name once, with const by default and let only for a name the code reassigns, such as the status line and the warnings count
  • Declare a name at the level where it’s read, such as let mode; before the if that sets it, because a let or const declared inside braces lives only inside them
  • Check a value’s type with typeof, compare the answer with a type name in quotes, and spot an array with Array.isArray()
  • Tell null, the empty value code sets on purpose, from undefined, the one an unset variable or a missing property gives you, and catch either with == null
  • Check for an empty string with !, an empty array by its .length, and an empty plain object by counting the keys returned by Object.keys()
  • Convert text with Number() once, where it comes in, and compare with === and !==

Keep the Habits That Carry Over

Locked learning resources

Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

Locked learning resources

The full lesson is for members only. Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

Become a Member to join the conversation.