Skip to content

Commit

Permalink
added try catch section
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed Nov 25, 2015
1 parent def1441 commit b00c053
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ function Point(x, y) {
this.y = y;
}

var p1 = new Point(11, 22);
var p2 = new Point(33, 44);
var p1 = new Point(11, 22); // => hidden Point class created
var p2 = new Point(33, 44); // => hidden Point class shared with p1
// At this point, p1 and p2 have a shared hidden class
p2.z = 55;
// warning! p1 and p2 now have different hidden classes!

p2.z = 55; // => another hidden class (Point') created, p1 !== p2
```

This might lead you to question how JavaScript performance could ever get anywhere close to C++. However, V8 has hidden types created internally for objects at runtime; objects with the same hidden class can then use the same optimized generated code.
Expand Down Expand Up @@ -178,14 +178,14 @@ The `Math` object contains properties and metods designed to make mathematical o

Each of these values is precalculated, so there is no need for you to calculate them yourself. There are also method to handle mathematical calculations:

| Method | Meaning |
|-------------------------|-----------------------------|
| `Math.abs(num)` | The absolute value of num |
| `Math.exp(num)` | Math.e**num |
| `Math.log(num)` | The logarithm of num |
| `Math.pow(num, power)` | num**power |
| `Math.sqrt(num)` | The square root of num |
| `Math.acos(x)` | The arc cosine of x |
| Method | Meaning |
|-------------------------|---------------------------|
| `Math.abs(num)` | The absolute value of num |
| `Math.exp(num)` | Math.e**num |
| `Math.log(num)` | The logarithm of num |
| `Math.pow(num, power)` | num**power |
| `Math.sqrt(num)` | The square root of num |
| `Math.acos(x)` | The arc cosine of x |


## Variable access over array/object access.
Expand Down Expand Up @@ -324,6 +324,10 @@ Is possible that you can gain an extra of perfomance using String method to matc

Check [test#1](https://jsperf.com/regexp-test-search-vs-indexof/12), [test#2](https://jsperf.com/regex-methods-x-1/2) & [test#3](https://jsperf.com/test-vs-indexof-fast/5) benchmarks.

## Don't handle too much code in a try/catch

Certain constructs like `try/catch` are considered not optimizable for the JavaScript engine, so avoid handle business logic inside. Just for pass an error as callback and this type of things.

## Avoid .bind, is slower.

In general terms, `.bind` the context with a `Function` generate need a considerable effort.
Expand Down

0 comments on commit b00c053

Please sign in to comment.