Code Monkey home page Code Monkey logo

Comments (17)

lzlu avatar lzlu commented on May 22, 2024 4

提个小意见,作为读者看到这篇文章略长。可以TOC一个目录,脉路清晰点,更容易消化。

from blog.

BBcaptain avatar BBcaptain commented on May 22, 2024 2

可以在chrome商店安装个TOC插件,https://chrome.google.com/webstore/detail/smart-toc/lifgeihcfpkmmlfjbailfpfhbahhibba
如图所示

from blog.

jawil avatar jawil commented on May 22, 2024 2
const obj = { a: 1, b: 2, c: 3 };

Object.defineProperty(obj, "a", {
  enumerable: false
});

for (let attr in obj) {
  console.log(attr);
}

不好意思,不可枚举属性不能被for in遍历,误导了,应该是'a' in obj是in检测对象属性会遍历对象自身的属性,以及原型属性,包括enumerable 为 false(不可枚举属性);
@shellphon

from blog.

jawil avatar jawil commented on May 22, 2024

TOC是啥?只看到Segment有这个,github好像没看到自带的这个。@Expelliarmus923

from blog.

Eamonnzhang avatar Eamonnzhang commented on May 22, 2024

Table of contents @jawil

from blog.

jawil avatar jawil commented on May 22, 2024

github有这个功能吗,应该说是markdown语法,好像文档没看到这个功能介绍。@Eamonnzhang

from blog.

jawil avatar jawil commented on May 22, 2024

感谢推荐,太实用了@BBcaptain

from blog.

congFly avatar congFly commented on May 22, 2024

写的非常好,很受用

from blog.

shellphon avatar shellphon commented on May 22, 2024

for-in循环:会遍历对象自身的属性,以及原型属性,包括enumerable 为 false(不可枚举属性);

不可枚举属性不能被for in遍历吧?……例子貌似也没支持这个说法

from blog.

yoky avatar yoky commented on May 22, 2024

博主,请教个问题,判断元素节点类型那一节,什么元素节点操作属性的时候用直接属性,什么时候用方法setAttribute?

from blog.

jawil avatar jawil commented on May 22, 2024

直接属性当然是直接挂在在元素节点上的属性,比如说 ele.textContent,input.vulue,而setAttribute是给元素节点加一个原来没有的属性,元素为了可拓展性,也允许加入自定义的属性。@yoky

举个例子吧,手和脚都是人自带的属性,但是我想飞,我可以去接(setAttribute)一双翅膀😂

from blog.

yoky avatar yoky commented on May 22, 2024

那可以用setAttribute修改本身自带属性的值么?

from blog.

jawil avatar jawil commented on May 22, 2024

写个 demo 试一下不就知道了,这个很好实践的啊,而且印象深刻 @yoky

from blog.

yoky avatar yoky commented on May 22, 2024

确实确实。。比心

from blog.

sfsoul avatar sfsoul commented on May 22, 2024

hello,针对9.1那块元素节点的判断,也可以用这段代码来判断,我觉得更方便点。
function isElementRight(node){
return window.HTMLElement ? node instanceof window.HTMLElement : !!node && node.nodeType === 1;
}
通过先判断传进来的值是否为HTMLElement的实例,就能过滤掉伪造的普遍对象a啦。

from blog.

caihg avatar caihg commented on May 22, 2024

@sfsoul 不能过滤这种伪造的元素对象
Object.create(HTMLElement.prototype, {
nodeType: {
value: 1
}
});

from blog.

sfsoul avatar sfsoul commented on May 22, 2024

@caihg ,感觉你这个例子就太偏激了。。。不过也的确过滤不了。不知道还有没有更好的办法呢

from blog.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.