summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--fa-ir/brainfuck-fa.html.markdown (renamed from fa-ir/brainfuck.html.markdown)0
-rw-r--r--fa-ir/javascript-fa.html.markdown (renamed from fa-ir/javascript.html.markdown)0
-rw-r--r--hu-hu/go-hu.html.markdown (renamed from hu-hu/go.html.markdown)0
-rw-r--r--hu-hu/ruby-hu.html.markdown (renamed from hu-hu/ruby.html.markdown)0
-rw-r--r--javascript.html.markdown41
-rw-r--r--ta_in/css-ta.html.markdown (renamed from ta_in/css.html.markdown)0
-rw-r--r--ta_in/javascript-ta.html.markdown (renamed from ta_in/javascript.html.markdown)0
-rw-r--r--ta_in/json-ta.html.markdown (renamed from ta_in/json.html.markdown)0
-rw-r--r--ta_in/xml-ta.html.markdown (renamed from ta_in/xml.html.markdown)0
9 files changed, 28 insertions, 13 deletions
diff --git a/fa-ir/brainfuck.html.markdown b/fa-ir/brainfuck-fa.html.markdown
index ef2bcba3..ef2bcba3 100644
--- a/fa-ir/brainfuck.html.markdown
+++ b/fa-ir/brainfuck-fa.html.markdown
diff --git a/fa-ir/javascript.html.markdown b/fa-ir/javascript-fa.html.markdown
index fe3555af..fe3555af 100644
--- a/fa-ir/javascript.html.markdown
+++ b/fa-ir/javascript-fa.html.markdown
diff --git a/hu-hu/go.html.markdown b/hu-hu/go-hu.html.markdown
index 638c9489..638c9489 100644
--- a/hu-hu/go.html.markdown
+++ b/hu-hu/go-hu.html.markdown
diff --git a/hu-hu/ruby.html.markdown b/hu-hu/ruby-hu.html.markdown
index 169f2b8e..169f2b8e 100644
--- a/hu-hu/ruby.html.markdown
+++ b/hu-hu/ruby-hu.html.markdown
diff --git a/javascript.html.markdown b/javascript.html.markdown
index cce488e1..cd75b0d2 100644
--- a/javascript.html.markdown
+++ b/javascript.html.markdown
@@ -16,9 +16,14 @@ JavaScript isn't just limited to web browsers, though: Node.js, a project that
provides a standalone runtime for Google Chrome's V8 JavaScript engine, is
becoming more and more popular.
+JavaScript has a C-like syntax, so if you've used languages like C or Java,
+a lot of the basic syntax will already be familiar. Despite this, and despite
+the similarity in name, JavaScript's object model is significantly different to
+Java's.
+
```js
-// Comments are like C's. Single-line comments start with two slashes,
-/* and multiline comments start with slash-star
+// Single-line comments start with two slashes.
+/* Multiline comments start with slash-star,
and end with star-slash */
// Statements can be terminated by ;
@@ -36,7 +41,7 @@ doStuff()
// JavaScript has one number type (which is a 64-bit IEEE 754 double).
// Doubles have a 52-bit mantissa, which is enough to store integers
-// up to about 9✕10¹⁵ precisely.
+// up to about 9✕10¹⁵ precisely.
3; // = 3
1.5; // = 1.5
@@ -136,7 +141,7 @@ undefined; // used to indicate a value is not currently present (although
// character.
var someVar = 5;
-// if you leave the var keyword off, you won't get an error...
+// If you leave the var keyword off, you won't get an error...
someOtherVar = 10;
// ...but your variable will be created in the global scope, not in the scope
@@ -145,7 +150,7 @@ someOtherVar = 10;
// Variables declared without being assigned to are set to undefined.
var someThirdVar; // = undefined
-// if you wan't to declare a couple of variables, then you could use a comma
+// If you want to declare a couple of variables, then you could use a comma
// separator
var someFourthVar = 2, someFifthVar = 4;
@@ -194,8 +199,6 @@ myObj.myFourthKey; // = undefined
///////////////////////////////////
// 3. Logic and Control Structures
-// The syntax for this section is almost identical to Java's.
-
// The `if` structure works as you'd expect.
var count = 1;
if (count == 3){
@@ -223,15 +226,15 @@ for (var i = 0; i < 5; i++){
// will run 5 times
}
-//The For/In statement loops iterates over every property across the entire prototype chain
+// The for/in statement iterates over every property across the entire prototype chain.
var description = "";
var person = {fname:"Paul", lname:"Ken", age:18};
for (var x in person){
description += person[x] + " ";
}
-//If only want to consider properties attached to the object itself,
-//and not its prototypes use hasOwnProperty() check
+// To only consider properties attached to the object itself
+// and not its prototypes, use the `hasOwnProperty()` check.
var description = "";
var person = {fname:"Paul", lname:"Ken", age:18};
for (var x in person){
@@ -240,8 +243,9 @@ for (var x in person){
}
}
-//for/in should not be used to iterate over an Array where the index order is important.
-//There is no guarantee that for/in will return the indexes in any particular order
+// For/in should not be used to iterate over an Array where the index order
+// is important, as there is no guarantee that for/in will return the indexes
+// in any particular order.
// && is logical and, || is logical or
if (house.size == "big" && house.colour == "blue"){
@@ -256,7 +260,7 @@ var name = otherName || "default";
// The `switch` statement checks for equality with `===`.
-// use 'break' after each case
+// Use 'break' after each case
// or the cases after the correct one will be executed too.
grade = 'B';
switch (grade) {
@@ -503,6 +507,10 @@ myNumber === myNumberObj; // = false
if (0){
// This code won't execute, because 0 is falsy.
}
+if (new Number(0)){
+ // This code will execute, because wrapped numbers are objects, and objects
+ // are always truthy.
+}
// However, the wrapper objects and the regular builtins share a prototype, so
// you can actually add functionality to a string, for instance.
@@ -547,6 +555,11 @@ of the language.
[JavaScript: The Definitive Guide][6] is a classic guide and reference book.
+[Eloquent Javascript][8] by Marijn Haverbeke is an excellent JS book/ebook with attached terminal
+
+[Javascript: The Right Way][9] is a guide intended to introduce new developers to JavaScript and help experienced developers learn more about its best practices.
+
+
In addition to direct contributors to this article, some content is adapted from
Louie Dinh's Python tutorial on this site, and the [JS Tutorial][7] on the
Mozilla Developer Network.
@@ -559,3 +572,5 @@ Mozilla Developer Network.
[5]: http://bonsaiden.github.io/JavaScript-Garden/
[6]: http://www.amazon.com/gp/product/0596805527/
[7]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/A_re-introduction_to_JavaScript
+[8]: http://eloquentjavascript.net/
+[9]: http://jstherightway.org/
diff --git a/ta_in/css.html.markdown b/ta_in/css-ta.html.markdown
index 56f94ed0..56f94ed0 100644
--- a/ta_in/css.html.markdown
+++ b/ta_in/css-ta.html.markdown
diff --git a/ta_in/javascript.html.markdown b/ta_in/javascript-ta.html.markdown
index f0b0a36a..f0b0a36a 100644
--- a/ta_in/javascript.html.markdown
+++ b/ta_in/javascript-ta.html.markdown
diff --git a/ta_in/json.html.markdown b/ta_in/json-ta.html.markdown
index d85e0d82..d85e0d82 100644
--- a/ta_in/json.html.markdown
+++ b/ta_in/json-ta.html.markdown
diff --git a/ta_in/xml.html.markdown b/ta_in/xml-ta.html.markdown
index a9bfa9cd..a9bfa9cd 100644
--- a/ta_in/xml.html.markdown
+++ b/ta_in/xml-ta.html.markdown