Skip to content
Permalink
Browse files

fixing editorconfig and changing tabs to 4-space

  • Loading branch information
getify committed Oct 21, 2019
1 parent 3e062d6 commit 17bfaa49eef7a4a03dcc3fbcc8443b3a1a848e4b
Showing with 41 additions and 29 deletions.
  1. +12 −0 .editorconfig
  2. +18 −18 getting-started/ch1.md
  3. +11 −11 getting-started/ch2.md
@@ -0,0 +1,12 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = tab
indent_size = 4

[*.md]
indent_style = space
indent_size = 4
@@ -119,17 +119,17 @@ Consider what the outcome of this program should be:
var x = true;
if (x) {
function gotcha() {
console.log("One!");
}
function gotcha() {
console.log("One!");
}
}
else {
function gotcha() {
console.log("Two!");
}
function gotcha() {
console.log("Two!");
}
}
gotcha(); // ??
gotcha(); // ??
```

While this may seem straightforward logically (print "One!"), the reality is much uglier. There are **many** different variations of this scenario, and each variation has slightly different semantics.
@@ -196,12 +196,12 @@ For example, a developer may write a snippet of code like:

```js
if (something) {
let x = 3;
console.log(x);
let x = 3;
console.log(x);
}
else {
let x = 4;
console.log(x);
let x = 4;
console.log(x);
}
```

@@ -211,12 +211,12 @@ This is how the code would look in the source code tree for that application. Bu
var x$0;
var x$1;
if (something) {
x$1 = 3;
console.log(x$1);
x$1 = 3;
console.log(x$1);
}
else {
x$2 = 4;
console.log(x$2);
x$2 = 4;
console.log(x$2);
}
```

@@ -254,9 +254,9 @@ A basic polyfill for `finally(..)` in pre-ES2019 environments could look like th

```js
if (!Promise.prototype.finally) {
Promise.prototype.finally = function f(fn){
return this.then(fn,fn);
};
Promise.prototype.finally = function f(fn){
return this.then(fn,fn);
};
}
```

@@ -72,7 +72,7 @@ Other than strings, JS programs often contain other primitive literal values suc

```js
while (false) {
console.log(3.141592);
console.log(3.141592);
}
```

@@ -107,7 +107,7 @@ Many developers prefer to treat them both consistently in this fashion, which is

```js
while (value != undefined) {
console.log("Still got something!");
console.log("Still got something!");
}
```

@@ -148,9 +148,9 @@ Consider:
var adult = true;
if (adult) {
var name = "Kyle";
let age = 39;
console.log("Shhh, this is a secret!");
var name = "Kyle";
let age = 39;
console.log("Shhh, this is a secret!");
}
console.log(name);
@@ -179,8 +179,8 @@ const myBirthday = true;
let age = 39;
if (myBirthday) {
age = age + 1; // OK!
myBirthday = false; // Error!
age = age + 1; // OK!
myBirthday = false; // Error!
}
```

@@ -193,7 +193,7 @@ const actors = [ "Morgan Freeman", "Jennifer Anniston" ];
actors[2] = "Tom Cruise"; // OK :(
actors = []; // Error!
actors = []; // Error!
```

The best semantic use of a `const` is when you have a simple primitive value that you want to give a useful name to, such as using `myBirthday` instead of `true`. This makes programs easier to read.
@@ -206,7 +206,7 @@ Besides `var` / `let` / `const`, there are other syntactic forms that declare id

```js
function hello(name) {
console.log(`Hello, ${name}.`);
console.log(`Hello, ${name}.`);
}
hello("Kyle");
@@ -221,10 +221,10 @@ Another syntax that declares a variable is the `catch` clause of a `try..catch`

```js
try {
someError();
someError();
}
catch (err) {
console.log(err);
console.log(err);
}
```

0 comments on commit 17bfaa4

Please sign in to comment.
You can’t perform that action at this time.