RubyLouvre/anu

View on GitHub
index2.html

Summary

Maintainability
Test Coverage
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width" />
        <script type="text/javascript" src="./dist/React.js"></script>
        <!-- <script type='text/javascript' src="./lib/ReactTestUtils.js"></script>
  <script type='text/javascript' src="./dist/ReactDOMServer.js"></script>-->

        <script
            type="text/javascript"
            src="./test/react.development.js"
        ></script>
        <script
            type="text/javascript"
            src="./test/react-dom.development.js"
        ></script>

        <script type="text/javascript" src="./lib/babel.js"></script>
    </head>

    <body>
        <div id="root" class="root"></div>
        <script>
function maxSubArray(nums) {
    var sum = nums[0];
    var max = nums[0];
    for(var i = 1;i < nums.length; i++) {
        if(max >0) {
          max += nums[i];
        }else{
          max = nums[i]
        }
        if(sum < max){
           sum = max;
        }
    }
    return sum;
}
console.log(maxSubArray([-2,1,-3,4,-1,2,1,-5,4]))
//javascript的进化 https://www.html.cn/archives/9925 https://www.cnblogs.com/crazycode2/p/9430155.html
// 0. JSON官方化
// 1. 异步的进化  callback, event,  Promise, generators, async/await
// 2. 作用域类型的增加 let  const
// 3. 基础类型的增加   symbol  BigInt
// 4. 类的标准化 class
// 5. 模块化的标准化
// 6. 原型方法的极大丰富 
// 7. 反射 set, get(针对单个属性), Object.defineProperty(针对单个属性,对低端浏览器友好), 
//  Object.seal/freeze/preventExtensions(针对多个属性), 
//  Reflect(Object.defineProperty的改良), 
//  Proxy(支持更多操作), 
// 8. 更甜的语法糖:
//      对象简写
//      **(冥运算), 
//      ...(浅拷贝), 
//      =>(箭头函数), 
//     for of(遍历可迭代对象的所有值, for in是遍历对象的键或索引)
//     1_222_333 (数字格式化),  https://www.jianshu.com/p/77f8130fd278
//    `hello ${world}` (字符串模板化与天然多行支持)

var obj = {
    a: 1,
    b: true,
    c: {
        d: 1
    }
}
var entries = Object.entries(obj);
//将数组再转换为对象fromEntries
var fromEntries = Object.fromEntries(entries);
console.log(fromEntries.c === obj.c)
var obj2 = {...obj}
console.log(obj2.c === obj.c)

        </script>
    </body>
</html>