Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Add missing reserved words: false, let, null, true, and yield. #295

Closed
wants to merge 1 commit into from

4 participants

@rwaldron
Collaborator

let and yield are FutureReservedWords and are only "reserved" in strict mode.

Furthermore... this list is very, very wrong (unrelated to your changes)

@rwaldron
Collaborator

This needs to be four lists... essentially something like this:

Null & Boolean Literals

- null
- true
- false

Reserved Words (Keywords)

- break
- case
- catch
- continue
- debugger
- default
- delete
- do
- else
- finally
- for
- function
- if
- in
- instanceof
- new
- return
- switch
- this
- throw
- try
- typeof
- var
- void
- while
- with

Future Reserved Words (unused, treated as Keywords)

- class
- const
- enum
- export
- extends
- import
- super

Future Reserved Words (unused, treated as Keywords in strict mode)

- implements
- interface
- let
- package
- private
- protected
- public
- static
- yield
@alimony

Since the purpose of the page (I guess) is to inform someone rather new to JavaScript that there are certain words that should be avoided for variable etc. names, the difference between your first three groups of words might not be that important; even if more correct.

What will matter to the reader/user is that some words will throw errors and others won't. So maybe the first two groups of words you mention could be put in one paragraph, with an explanation saying that they will cause an error because they are "parts of the language" or something similar. The third and fourth groups could be put in another paragraph with an explanation saying that they may end up as part of the language and should be avoided too.

Maybe a distinction should be kept between what will happen in strict mode and not (i.e. separating group three and four), but could that also cause confusion? Having just two groups, the "Don't use these" and the "Avoid these too" has some simplicity to it.

These are just some thoughts. What do you think @rwldrn?

@rwaldron
Collaborator

@alimony more to the point: the existing list is wrong. you can file a PR or I will just fix it.

@alimony

@rwldrn Opened #301 for correcting the list. Even though the full list is only considered reserved in strict mode, it is more correct than the previous one…

@rwaldron
Collaborator

Love it!

@ajpiano
Collaborator

#301 is merged. Is there anything else we need to do from this ticket being open -- perhaps the grouping @rwldrn proposed?

@rdworth

As this is intro-level content I actually think a single list (not grouped) makes more sense

@rwaldron
Collaborator

Nope, @alimony's list is good for me

@ajpiano
Collaborator

Great!

@ajpiano ajpiano closed this
@alimony alimony deleted the branch
@alimony alimony restored the branch
@gnarf gnarf referenced this pull request from a commit in gnarf/learn.jquery.com
@alimony alimony Update list of reserved words in JavaScript. Fixes #301.
All of these are only considered reserved when in strict mode, but it is in any case a more correct list than the current one. See jquery#295 for further discussion on how to present this list.
9efaf07
@arthurvr arthurvr referenced this pull request from a commit in arthurvr/learn.jquery.com
@alimony alimony Update list of reserved words in JavaScript. Fixes #301.
All of these are only considered reserved when in strict mode, but it is in any case a more correct list than the current one. See jquery#295 for further discussion on how to present this list.
7e0a0d0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 5 additions and 0 deletions.
  1. +5 −0 page/javascript-101/reserved-words.md
View
5 page/javascript-101/reserved-words.md
@@ -26,6 +26,7 @@ JavaScript has a number of “reserved words,” or words that have special mean
- enum
- export
- extends
+- false
- final
- finally
- float
@@ -39,9 +40,11 @@ JavaScript has a number of “reserved words,” or words that have special mean
- instanceof
- int
- interface
+- let
- long
- native
- new
+- null
- package
- private
- protected
@@ -56,6 +59,7 @@ JavaScript has a number of “reserved words,” or words that have special mean
- throw
- throws
- transient
+- true
- try
- typeof
- var
@@ -63,3 +67,4 @@ JavaScript has a number of “reserved words,” or words that have special mean
- volatile
- while
- with
+- yield
Something went wrong with that request. Please try again.