In code examples, // ... represents omitted code:
function processData(data) {
validate(data);
// ...
return result;
}
The ellipsis means "implementation details go here but aren't shown."
What It Means
// ... is shorthand for "there's more code here, but it's not relevant to this example." It focuses the reader on what matters.
Without it, examples would be verbose:
// With ellipsis - focused
function handle Request(req) {
const user = authenticate(req);
// ...
return response;
}
// Without - distracting
function handleRequest(req) {
const user = authenticate(req);
const data = validateInput(req.body);
const result = processData(data);
const formatted = formatResponse(result);
logRequest(req);
updateMetrics('requests');
checkRateLimit(user);
return response;
}
Common Contexts
Implementation details:
class UserService {
async getUser(id) {
// ... database query
return user;
}
}
Boilerplate code:
import express from 'express';
const app = express();
// ... middleware setup
app.listen(3000);
Loop bodies:
for (const item of items) {
// ... process item
}
Variations
Different forms mean the same thing:
// ...
// ...rest of implementation
// ...more code here
// (implementation omitted)
/* ... */
Language-Specific
Each language uses its comment syntax:
// JavaScript, C, C++, Java
function example() {
// ...
}
# Python, Ruby
def example():
# ...
-- SQL
SELECT * FROM users
-- ...
WHERE active = true;
<!-- HTML -->
<div>
<!-- ... -->
</div>
Not Runnable Code
Code with // ... isn't meant to run as-is:
// This won't execute
function broken() {
const x = 5;
// ...
return result; // 'result' undefined
}
It's documentation, not production code.
Versus Actual Ellipsis Operator
Don't confuse with JavaScript's spread operator:
// Actual code - spread operator
const arr = [...oldArray, newItem];
// Comment - placeholder
function example() {
// ...
}
In Documentation
API docs use it for brevity:
fetch('/api/users')
.then(response => response.json())
.then(data => {
// ... handle data
});
Before and After Patterns
Teaching examples use it to show changes:
// Before
function oldWay() {
// ...
return result;
}
// After
function newWay() {
// ... (same as before)
return improvedResult;
}
Different from TODO
// ... means "code exists but isn't shown." // TODO means "code needs to be written":
// Documentation - code exists elsewhere
function example() {
// ...
}
// Production - code missing
function incomplete() {
// TODO: implement validation
}
Reader Expectations
When you see // ..., understand:
- The example is simplified
- You're meant to fill in the gaps
- Focus on the shown code
- Context clues indicate what's omitted
Writing Examples with Ellipsis
Good use - clear context:
async function saveUser(user) {
// ... validation
await db.save(user);
// ... logging
}
Bad use - unclear what's omitted:
function mystery() {
// ...
}
Further Reading
MDN's code example guidelines cover documentation conventions.
The ellipsis comment is a documentation convention, not syntax.
0 comments