Why does the output of the stack have undefined

the js code is as follows:

    function Stack(){
        let items = [];
        // 
        this.push = function(element) {
            items.push(element);
        }
        this.pop = function(){
            return items.pop();
        }
        // 
        this.peek = function(){
            return items[items.length-1];
        }
        this.isEmpty = function(){
            return items.length == 0;
        }
        this.size = function(){
            return items.length;
        }
        this.clear = function(){
            items = [];
        }
        this.print = function(){
            console.log(items.toString());
        }
    }
    
    let st = new Stack();
    console.log(st.isEmpty());
    st.push(1);
    st.push(2);
    st.push(3);
    console.log(st.peek());
    console.log(st.isEmpty());
    console.log(st.print());
    st.pop();
    console.log(st.print());

the output result is
true
3
false
1
undefined
1
undefined

Mar.03,2021

your print has already been printed inside, why print it again on the outside? Is it questionable that the


print method does not return a value?

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3d33b-2c36a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3d33b-2c36a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?