Skip to content
Closed
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
1afacaa
style conformance for about-jquery/how-jquery-works
Nov 7, 2012
a98b0bf
style conformance for javascript-101/getting-started
Nov 7, 2012
776c4aa
style conformance for javascript-101/syntax-basics
Nov 7, 2012
f7641f4
style conformance for javascript-101/running-code
Nov 7, 2012
87ce1f2
style conformance for javascript-101/types
Nov 8, 2012
74be2db
style conformance for javascript-101/operators
Nov 8, 2012
cc01ee8
style conformance for javascript-101/conditional-code
Nov 8, 2012
2b4cf16
found the section on truthy/falsy
Nov 8, 2012
70b2003
style conformance for javascript-101/loops
Nov 8, 2012
6b04bb6
style conformance for javascript-101/arrays
Nov 8, 2012
0d7b57e
adding links to objects/arrays sections
Nov 8, 2012
f97c941
style conformance for javascript-101/objects
Nov 8, 2012
47fda0e
style conformance for javascript-101/functions
Nov 8, 2012
e498797
style conformance for javascript-101/testing-type
Nov 8, 2012
f1c8aff
link to testing-type section
Nov 8, 2012
2254121
style conformance for javascript-101/this-keyword
Nov 8, 2012
2dfb23a
style conformance for javascript-101/scope
Nov 8, 2012
1cb18ad
style conformance for javascript-101/closures
Nov 8, 2012
4259929
horizontal scrolling issues
Nov 8, 2012
a709de1
consistency with —
Nov 8, 2012
adcbaeb
style conformance for using-jquery-core/dollar-object-vs-function
Nov 8, 2012
bbe819e
style conformance for using-jquery-core/document-ready
Nov 8, 2012
bc6b21c
style conformance for using-jquery-core/avoid-conflicts-other-libraries
Nov 8, 2012
24b91ce
style conformance for using-jquery-core/attributes
Nov 8, 2012
8989211
style conformance for using-jquery-core/selecting-elements
Nov 8, 2012
d8c1ff5
style conformance for using-jquery-core/working-with-selections
Nov 9, 2012
3f9e54a
style conformance for using-jquery-core/manipulating-elements
Nov 9, 2012
947dff6
style conformance for using-jquery-core/data-methods
Nov 9, 2012
b17307b
style conformance for using-jquery-core/utility-methods
Nov 9, 2012
40c11cf
style conformance for using-jquery-core/jquery-object
Nov 9, 2012
96f06d4
style conformance for using-jquery-core/traversing
Nov 9, 2012
a52fe58
style conformance for using-jquery-core/css-styling-dimensions
Nov 9, 2012
6256c9e
style conformance for using-jquery-core/iterating
Nov 9, 2012
8f96503
style conformance for using-jquery-core/understanding-index
Nov 9, 2012
e512536
deleting obsolete exercises.md page
Nov 9, 2012
d6d5dcb
Update config-sample to reflect local.* instead of dev.*
ajpiano Nov 9, 2012
4ae27eb
Upgrade to grunt-jquery-content 0.5.10, add grunt-check-modules to gr…
ajpiano Nov 9, 2012
495a7b0
README.md updates
ajpiano Nov 9, 2012
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
style conformance for javascript-101/syntax-basics
  • Loading branch information
jorydotcom committed Nov 7, 2012
commit 776c4aa163c7a5d397b8790dc14435e3fcd58ed4
17 changes: 8 additions & 9 deletions page/javascript-101/syntax-basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ attribution:

### Comments

JavaScript has support for single and multi line comments. Comments are ignored by the JavaScript engine, therefore have no side-effects on the outcome of the program. They should be used to document the code for future developers (including yourself!). There are libraries available that can generate project documentation pages based on commenting conventions used, [JSDoc](http://code.google.com/p/jsdoc-toolkit/, "JSDoc Toolkit") is one of the more popular ones.
JavaScript has support for single and multi-line comments. Comments are ignored by the JavaScript engine and therefore have no side-effects on the outcome of the program. Use comments to document the code for other developers. Libraries like [JSDoc](http://code.google.com/p/jsdoc-toolkit/, "JSDoc Toolkit") are available to help generate project documentation pages based on commenting conventions.

```
// Single and multi line comments.
Expand All @@ -24,18 +24,18 @@ JavaScript has support for single and multi line comments. Comments are ignored

### Whitespace

Whitespace is also ignored in JavaScript. There are many tools that will actully strip out all the whitespace in a program reducing the overall file size in order to improve network latency. Given the availability of tools like these, whitespace should be leveraged to make the code as readible as possible.
Whitespace is also ignored in JavaScript. There are many tools that will strip out all the whitespace in a program, reducing the overall file size and improving network latency. Given the availability of tools like these, whitespace should be leveraged to make the code as readible as possible.

```
// Whitespace is insignifigant.
// Whitespace is insignificant.
var hello = "Hello";

var world = "World!";
```

```
// Semantic whitespace promotes readibility.
// readible code is good!
// Readible code is good!
var foo = function() {

for ( var i = 0; i < 10; i++ ) {
Expand All @@ -48,23 +48,23 @@ var foo = function() {

foo();

// not so much!
// This is much harder to read!
var foo=function() {for(var i=0;i<10;++){alert(i);}};foo();
```

### Reserved Words

There is a handfull of reserved words that cannot be used when declaring user defined variables and functions. Some of these are currently implemented, some for future use, and others for historical reasons. A list of words and in depth explaination can be found on the [MDN JavaScript Reference](https://developer.mozilla.org/en/JavaScript/Reference/Reserved_Words, "MDN Reserved Words.")
There are a handfull of reserved words that can't be used when declaring user-defined variables and functions. Some of these reserved words are currently implemented, some are saved for future use, and others are reserved for historical reasons. A list of words and in-depth explanations for each can be found on the [MDN JavaScript Reference](https://developer.mozilla.org/en/JavaScript/Reference/Reserved_Words, "MDN Reserved Words.") site.

### Identifiers

Identifiers are used to name variables and functions with a unique name so they can subsequently be refererred to by that name; variables and functions will be discussed in a later chapter. The name of an identifier must follow a few rules:
Identifiers are used to give variables and functions a unique name so they can subsequently be referred to by that name. The name of an identifier must follow a few rules:

* Cannot be a reserved word.
* Can only be composed of letters, numbers, dollar signs, and underscores.
* The first character cannot be a number.

It is best practice to name these identifiers to something that will make sense to other developers and to you later on.
It's a best practice to name identifers in a way that will make sense to you and other developers later on.

```
// Valid identifier names.
Expand All @@ -75,4 +75,3 @@ var $my_AwesomeVariable = "d";
var _my_awesome_variable_$ = "e";
```

While it is possible to run JavaScript in server-side environments, that is out of the scope for this section.