Comments (17)
提个小意见,作为读者看到这篇文章略长。可以TOC一个目录,脉路清晰点,更容易消化。
from blog.
可以在chrome商店安装个TOC插件,https://chrome.google.com/webstore/detail/smart-toc/lifgeihcfpkmmlfjbailfpfhbahhibba
如图所示
from blog.
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.
TOC是啥?只看到Segment有这个,github好像没看到自带的这个。@Expelliarmus923
from blog.
Table of contents @jawil
from blog.
github有这个功能吗,应该说是markdown语法,好像文档没看到这个功能介绍。@Eamonnzhang
from blog.
感谢推荐,太实用了@BBcaptain
from blog.
写的非常好,很受用
from blog.
for-in循环:会遍历对象自身的属性,以及原型属性,包括enumerable 为 false(不可枚举属性);
不可枚举属性不能被for in遍历吧?……例子貌似也没支持这个说法
from blog.
博主,请教个问题,判断元素节点类型那一节,什么元素节点操作属性的时候用直接属性,什么时候用方法setAttribute?
from blog.
直接属性当然是直接挂在在元素节点上的属性,比如说 ele.textContent,input.vulue,而setAttribute是给元素节点加一个原来没有的属性,元素为了可拓展性,也允许加入自定义的属性。@yoky
举个例子吧,手和脚都是人自带的属性,但是我想飞,我可以去接(setAttribute)一双翅膀😂
from blog.
那可以用setAttribute修改本身自带属性的值么?
from blog.
写个 demo 试一下不就知道了,这个很好实践的啊,而且印象深刻 @yoky
from blog.
确实确实。。比心
from blog.
hello,针对9.1那块元素节点的判断,也可以用这段代码来判断,我觉得更方便点。
function isElementRight(node){
return window.HTMLElement ? node instanceof window.HTMLElement : !!node && node.nodeType === 1;
}
通过先判断传进来的值是否为HTMLElement的实例,就能过滤掉伪造的普遍对象a啦。
from blog.
@sfsoul 不能过滤这种伪造的元素对象
Object.create(HTMLElement.prototype, {
nodeType: {
value: 1
}
});
from blog.
@caihg ,感觉你这个例子就太偏激了。。。不过也的确过滤不了。不知道还有没有更好的办法呢
from blog.
Related Issues (20)
- test
- question
- 学习了!
- 安利一下自己为 GitHub 开发的首个 Chrome 插件—GayHub😂 HOT 51
- CSS 黑魔法小技巧,让你少写不必要的JS,代码更优雅 HOT 47
- JavaScript 优雅的实现方式包含你可能不知道的知识点 HOT 44
- blog搬家了?请放出地址呦 HOT 2
- 一行代码实现一个简单的模板字符串替换 HOT 17
- 哥们你域名过期了 http://qdxmq.com/ HOT 1
- add方法里的数组有没有必要抽出一个config.js文件 HOT 1
- 3 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 #------------------------------------------------- # # Project created by QtCreator 2018-10-25T08:32:36 # #------------------------------------------------- QT += core gui QT += serialport greaterThan(QT_MAJOR_VERSION, 4): QT += widgets TARGET = COMTOOLV2 TEMPLATE = app RC_FILE =main.rc # The following define makes your compiler emit warnings if you use # any feature of Qt which has been marked as deprecated (the exact warnings # depend on your compiler). Please consult the documentation of the # deprecated API in order to know how to port your code away from it. DEFINES += QT_DEPRECATED_WARNINGS # You can also make your code fail to compile if you use deprecated APIs. # In order to do so, uncomment the following line. # You can also select to disable deprecated APIs only up to a certain version of Qt. #DEFINES += QT_DISABLS HOT 2
- a == 1 && a == 2 && a == 3 输出true方法
- 前端小蜜圈链接跳转到了菠菜站了 HOT 2
- PM2部署网站的一个诡异缓存问题
- echo 127.0.0.1
- vue项目 HOT 1
- m
- 停更了?
- 三次握手与四次挥手
- 有人继续维护吗? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from blog.