Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

怎么直观看是否可枚举~ #1

Open
2 tasks done
lvleihere opened this issue Nov 24, 2018 · 0 comments
Open
2 tasks done

怎么直观看是否可枚举~ #1

lvleihere opened this issue Nov 24, 2018 · 0 comments

Comments

@lvleihere
Copy link
Owner

lvleihere commented Nov 24, 2018

在控制台看,高亮的就是可枚举的,哈哈

举例举例:

ES5构造函数创建实例对象:

function Parent() {
    this.name = 'lvlei';
}
Parent.prototype.show = () => {
    console.log('show');
}

let parent = new Parent();
console.log(parent);

可以只直观看出,nameshow字段是可枚举(高亮)的嘛
image

再看看通过ES6语法的class创建的实例对象:

class Parent {
    constructor() {
        this.name = 'lvlei';
    }
    show() {

    }
}

let parent = new Parent();
console.log(parent);

可以只直观看出,name字段是可枚举(高亮)的,而show是不可枚举(没高亮)的~

image

支持浏览器

  • chrome
  • opera
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant