The following code adds a [placeholder] class name to the <body>
element:
document.body.classList.add( "foo-bar" );
Question: How should the class name inserted at [placeholder] be formatted?
- 1: foo-bar
- 2: "foo-bar"
- 3: “foo-bar”
- 4:
foo-bar
- 5:
"foo-bar"
- 6: “
foo-bar
”
#4. The context here is the actual class name, so it shouldn't be quoted. Because class names are meaningful values, they should be highlighted as code.
If you change the context slightly, then #5 is correct, e.g., We will pass
"foo-bar"
toclassList.add()
.