From 3e36d0aae4420e17dc6a296dcb77f0b873f4b223 Mon Sep 17 00:00:00 2001 From: dscanlonpa Date: Tue, 24 Dec 2013 13:31:25 -0500 Subject: [PATCH 1/3] Update README.md Added bit about naming variables with consideration to context implied by scope. --- README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/README.md b/README.md index b213bb8122..cfa1394c3d 100644 --- a/README.md +++ b/README.md @@ -999,6 +999,22 @@ // ..stuff.. } ``` + + - Allow scope to imply context for names. Be sure to use meaningful names to differentiate items of similar nature. + + ```javascript + // bad + function sendMessageToUser(user1, user2) { + var date = Date(); + // ...stuff... + } + + // good + function sendMessageToUser(sender, recipient) { + var messageCreationDate = Date(); + // ..stuff.. + } + ``` - Use camelCase when naming objects, functions, and instances From e5f9c9599f781bbd6be23e524134af9de90fe4b2 Mon Sep 17 00:00:00 2001 From: dscanlonpa Date: Tue, 24 Dec 2013 13:32:12 -0500 Subject: [PATCH 2/3] Present JavaScript Style Guide now! --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cfa1394c3d..ad94206998 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Airbnb JavaScript Style Guide() { +# Present JavaScript Style Guide() { *A mostly reasonable approach to JavaScript* From cf6280a9671859d71e9fb33aa78f75c51478fffd Mon Sep 17 00:00:00 2001 From: dscanlonpa Date: Tue, 24 Dec 2013 13:38:49 -0500 Subject: [PATCH 3/3] Added to variable naming example about context. --- README.md | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ad94206998..e28320995f 100644 --- a/README.md +++ b/README.md @@ -1005,13 +1005,23 @@ ```javascript // bad function sendMessageToUser(user1, user2) { - var date = Date(); + var date = Date(), + message = { + body: 'hey', + messageCreationDate: date + }; + // ...stuff... } // good function sendMessageToUser(sender, recipient) { - var messageCreationDate = Date(); + var messageCreationDate = Date(), + message = { + body: 'hey', + creationDate: messageCreationDate + }; + // ..stuff.. } ```