### 1.Fibonacci--
[O(2n)](http://stackoverflow.com/questions/360748/computational-complexity-of-fibonacci-sequence/360773#360773)
```js
function fibonacci(n) {
return n < 2 ? n : fibonacci(n-1) + fibonacci(n-2);
}
```
### 2.
```js
function maxInArray(arr) {
return Math.max.apply(Math, arr);
}
```
### 3.
```js
String.prototype.reverse = function() {
return this.split('').reverse().join('');
}
```
or
```js
String.prototype.reverse = function() {
var str = '';
var len = this.length;
while (len>0) {
str += this.substring(len-1, len);
len--;
}
return str;
}
```
: 'foo bar'astral symbol,
[ Esrever](https://github.com/mathiasbynens/esrever)
### 4.DOM
```js
function reverseDom(el){
var frag = document.createDocumentFragment();
while(el.lastChild){
frag.appendChild(el.lastChild);
}
el.appendChild(frag);
}
```
DOM
documentFragment
appendChildappendChildDOM,,
### 5.
```js
function removeDuplicateChar(str){
var strArr = str.split('');
var targetArr = [];
strArr.forEach(function(item){
if (strArr.indexOf(item) === strArr.lastIndexOf(item)) {
targetArr.push(item)
}
})
//
return targetArr.join('').split(' ').join('');
}
```
### 6. (palindrome)
Bulid-in Method
```js
function isPalindrom(str) {
return str === str.split('').reverse().join('');
}
```
```js
function isPalindrome(str){
var i, len = str.length;
//
for(i =0; i0){
count += Math.floor(n/10);
n = n/10;
}
return count;
}
```
### 8.(permutation)
[see](http://www.lifelaf.com/blog/?p=1228)
```js
/**
* Created by cshao on 12/23/14.
*/
function getPermutation(arr) {
if (arr.length == 1) {
return [arr];
}
var permutation = [];
for (var i=0; i