Ad
  • Custom User Avatar
    function factor(){
        let result = '';
        if(peek() > '0' && peek() < '9') return number();
    

    calc('9+1') return emtpy string

    so, You should write if(peek() > '0' && peek() <= '9').

  • Custom User Avatar
  • Custom User Avatar
  • Custom User Avatar

    Hello, after listening to your advice,

    I have made some tests as follows, but I have not found that Array.from is slower than [...Arr].

    console.time("timer")
    obj=document.querySelectorAll('a')
    for(let i=1;i<9999999;++i){obj[i]=i}
    [...obj]
    console.timeEnd("timer");
    VM299:5 timer: 948.02685546875ms
    
    
    console.time("timer")
    obj=document.querySelectorAll('a')
    for(let i=1;i<9999999;++i){obj[i]=i}
    Array.from(obj)
    console.timeEnd("timer");
    VM300:5 timer: 943.575927734375ms
    
    console.time("timer")
    obj=document.querySelectorAll('a')
    for(let i=1;i<999;++i){obj[i]=i}
    [...obj]
    console.timeEnd("timer");
    VM340:5 timer: 0.406005859375ms
    
    console.time("timer")
    obj=document.querySelectorAll('a')
    for(let i=1;i<999;++i){obj[i]=i}
    Array.from(obj)
    console.timeEnd("timer");
    VM341:5 timer: 0.410888671875ms
    
    My Configuration

    Google chrome
    Version 65.0.3325.181 ( official version ) ( 64 bits )

    I guess it must have something to do with V8.