SOURCE

console 命令行工具 X clear

                    
>
console
(function(){
    function image(_src, _width, _height)
    {
        this.src = _src;
        this.width = _width;
        this.height = _height;
    }

    var p = new image('https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fb.zol-img.com.cn%2Fdesk%2Fbizhi%2Fimage%2F1%2F1680x1050%2F1349289433496.jpg&refer=http%3A%2F%2Fb.zol-img.com.cn&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1624200037&t=987d5055048f9b11b5062c51408660cb', 1680,1050);
    p.name = '美女'
    p.desc = '长头发'
    p.print_image = function(){
        document.write('名称:' + this.name + '<br />')
        document.write('描述:' + this.desc + '<br />')
        document.write('<image src="'+this.src+'" width="'+this.width+'" height="'+this.height+'" />')
    }

    image.prototype.test = function(){
        console.log(JSON.stringify(this))
    }

    // p.print_image()
    with(p) {
        document.write('名称:' + name + '<br />')
        document.write('描述:' + desc + '<br />')
        document.write('<image src="'+src+'" width="'+width+'" height="'+height+'" />')
    }
    p.test()
})()
<html>
    <body>
	<div>test</div>
</body>
</html>