Locked learning resources

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

Unlock This Lesson

Locked learning resources

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

Unlock This Lesson

Renaming Python Names for JavaScript

Renaming Python Names for JavaScript

Rename as you port the release note. Underscores are legal in JavaScript identifiers, but variables and functions conventionally use camelCase: open_bugs → openBugs and print_header → printHeader. Update declarations and uses together.

The six fixed settings keep UPPER_SNAKE_CASE here. const prevents rebinding; capitals mark settings rather than every const. The computed openBugs remains camelCase.

Classes, when you meet them, use PascalCase, such as ReleaseNote. A dollar sign is legal in a JavaScript identifier, such as $openBugs; expect it in library names rather than adopting it for your variables.

Some ordinary Python names are reserved in JavaScript: default, delete, new, and package in strict mode, including modules. Using them as names causes a SyntaxError. Pick meaningful alternatives, such as defaultChannel for the client’s channel.

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

00:00 The release note’s snake case port runs. Underscores are legal, but JavaScript readers expect camel case for variables and functions. You’ll rename the port’s names.

00:12 For variables and functions, JavaScript uses camel case where Python uses snake case: the first word lowercase, and each word after it capitalized. open_bugs drops its underscore and gains a capital B.

00:27 print_header() changes the same way, where it’s declared and where it’s called. Classes, when you meet them, use Pascal case, like Python’s CapWords.

00:38 A JavaScript name can hold a dollar sign, which you’ll see in library names but shouldn’t use for your own variables.

00:47 Both declarations use const. Your turn: should the computed openBugs name become all capitals too? Pause the video and choose.

01:01 Keep openBugs in camel case. The six settings keep their capitals. Many projects write top-level settings that someone edits in upper snake case.

01:14 In JavaScript, const prevents rebinding. Capitals mark fixed settings, not every const. If you capitalized every const, restore camel case for computed values.

01:28 Python’s channel name default becomes defaultChannel. JavaScript reserves default, delete and new for its syntax, and package in strict mode, including modules.

01:41 Using them as names causes a SyntaxError; choose meaningful replacements.

01:48 For the file name, use kebab case: lowercase words joined by hyphens. Many projects use this convention; underscores are legal too. Run the renamed file: the same header as Python, now with its channel.

02:04 Rename as you port. Next up is Letting a Formatter Decide the Style, a text lesson: give the release note consistent layout after choosing its names.

Become a Member to join the conversation.