SOURCE

console 命令行工具 X clear

                    
>
console
// document.getElementById('list').addEventListener('click', function(e) {
//     const target = e.target
//     let p = e.target.parentNode
//     let index = Array.prototype.indexOf.call(p.children, e.target);
//     // console.log('rag', p.children.indexOf(e.target))
//     if (target.nodeName.toLocaleLowerCase() === 'li') {
//         console.log('the content is: ', index);
//     }
// })

// var User = {
//     count: 1,
//     action: {
//         getCount: function() {
//             return this.count
//         }
//     }
// }
// var getCount = User.action.getCount
// setTimeout(() => {
//     console.log('result 1', User.action.getCount())
// })
// console.log('result 2', getCount())

// function milliFormat(num) {

//     return num && num.toString()
//         .replace(/\d+/, function(s){
//              return s.replace(/(\d)(?=(\d{3})+$)/g, '$1,')
//          })
// }
// console.log(milliFormat(-1234567.1234))
    // function LazyMan(name) {
    //   const queue = [];
    //   const lazyMan = {
    //     sayHi() {
    //       queue.push(() => {
    //         console.log(`hi this is ${name}`);
    //         this.next();
    //       });
    //     },
    //     eat(food) {
    //       queue.push(() => {
    //         console.log(`eat ${food}`);
    //         this.next();
    //       });
    //       return this;
    //     },
    //     sleep(time) {
    //       queue.push(() => {
    //         setTimeout(() => {
    //           console.log(`wake up after ${time}s`);
    //           this.next();
    //         }, time * 1000);
    //       });
    //       return this;
    //     },
    //     sleepFirst(time) {
    //       queue.unshift(() => {
    //         setTimeout(() => {
    //           console.log(`wake up after ${time}s`);
    //           this.next();
    //         }, time * 1000);
    //       });
    //       return this;
    //     },
    //     next() {
    //       const fn = queue.shift();
    //       fn && fn();
    //     },
    //   };
    
    //   lazyMan.sayHi();
    //   setTimeout(() => {
    //     lazyMan.next();
    //   });
    //   return lazyMan;
    // }
    
    // // LazyMan('hhh')
    // //   .sleep(5)
    // //   .eat('apple')
    // //   .sleepFirst(3);
    // LazyMan('Hank').sleepFirst(5).eat('supper')
const nums = [-2, 0, 3, -5, 2, -1]
const NumArray = function(nums) {
  this.array = [nums[0]];
  for (let i = 1, len = nums.length; i < len; i++) {
    this.array.push(nums[i] + this.array[i-1]);
  }
};

NumArray.prototype.sumRange = function(i, j) {
  return (i === 0) ? this.array[j] : (this.array[j] - this.array[i-1]);
}
NumArray(nums)
console.log('sumRange', NumArray.prototype.sumRange(0, 2))
// NumArray.prototype.sumRange(0, 2)
<ul id="list">
	<li>2</li>
	<li>22</li>
	<li>222</li>
	<li></li>
	<li></li>
	<li></li>
	<li></li>
	<li></li>
	<li></li>
	<li></li>
	<li></li>
	<li></li>
	<li></li>
	<li></li>
	<li></li>
	<li></li>
	<li></li>
	<li></li>
	<li></li>
	<li></li>
</ul>