Wing Meng

Results 75 comments of Wing Meng

```js const object1 = { userid: 123, username: '王二', tel: '13208033621' }; ``` #### 第 1 题: 一句话:两者都会对 URL 中的特殊字符进行编码,区别是两者编码的字符范围不一样,前者不会对属于 URI 的特殊字符进行编码,而后者会。 #### 第 2 题: ```js Object.keys(object1) .map(key =>...

[> 在线 Demo .iconfont { margin-bottom: .5rem; font-size: 2rem; line-height: 1; } ``` ```html 商品秒杀 企业团购 私码通道 铁粉卡 以旧换新 话费充值 ```

#### 第 1 题: ```js const dialog = document.createElement('dialog'); document.body.appendChild(dialog); ``` #### 第 2 题: ```js // 方法1: dialog.open = true; // 或其他为“真值”的基本类型,如 1,"abc" 等 // 方法2: dialog.show(); // 方法3:...

#### 第 1 题:arr 的长度是多少? 解析:数组中的空元素 (empty 元素) 也会被算到数组长度中 ```js console.log(arr.length); // 4 ``` #### 第 2 题:去除 arr 中的空数组项 解析:数组中的 empty 元素不会参与数组项遍历,故只需返回 true 即可过滤掉 empty 元素(而不会牵连 `0`、`NaN`、`null`、`undefined`、`''` 这些) ```js...

预期是达到了,就是算法复杂度有点高了…… [> 测试 DEMO

[> 在线 Demo

我的回答:用 jQuery 的 [`closest()`](https://api.jquery.com/closest/) 方法。开个玩笑 :laughing: 先说下思路:根据传入的参数,使用 `querySelectorAll()` 方法找出所有匹配的选择器,再匹配出包含当前元素的 nodeList 列表。 #### 第二题 > 第一题依赖这个方法,所以它先上 ``` js Element.prototype.closestAll = function(targetEl) { var el = this; var nodelist; // 参数校验 if...

- 第 1 题:`document.cookie` - 第 2 题:`document.cookie = 'userid=1';` - 第 3 题: ```js var expires = 24 * 36e5; // 过期时间:1 天 document.cookie = 'userid=1; expires=' + (new...

#### 第 1 题: ```js // 方法1 const myTextarea = document.querySelector('textarea'); // 方法2 const myTextarea = document.getElementsByTagName('textarea')[0]; ``` #### 第 2 题: ```js // 方法1 myTextarea.rows = 5; // 方法2...

[> 在线 Demo .btn:not(:first-child), .btn-group > .details-menu:not(:first-child) {margin-left: -1px;} .btn-group > .btn:first-child, .btn-group > .details-menu:first-child > .btn { border-top-left-radius: .25em; border-bottom-left-radius: .25em; } .btn-group > .btn:last-child, .btn-group > .details-menu:last-child >...