程序员依扬

Results 48 comments of 程序员依扬

> 附录A 动态作用域 这个示例里的动态作用域例子和上面重复了吧 没有啊

```js // example 1 var a={}, b='123', c=123; a[b]='b'; a[c]='c'; console.log(a[b]); --------------------- // example 2 var a={}, b=Symbol('123'), c=Symbol('123'); a[b]='b'; a[c]='c'; console.log(a[b]); --------------------- // example 3 var a={}, b={key:'123'}, c={key:'456'};...

```js var a = {n: 1}; var b = a; a.x = a = {n: 2}; console.log(a.x) console.log(b.x) ```

```js var obj = { '2': 3, '3': 4, 'length': 2, 'splice': Array.prototype.splice, 'push': Array.prototype.push } obj.push(1) obj.push(2) console.log(obj) ```

```js var b = 10; (function b(){ b = 20; console.log(b); })(); ```

```js var b = 10; (function b(){ b = 20; console.log(b); })(); ```

可从IIFE、AMD、CMD、CommonJS、UMD、webpack(require.ensure)、ES Module、`` 这几个角度考虑。

```js var a = ?; if(a == 1 && a == 2 && a == 3){ console.log(1); } ```

给定一个数组,将数组中的元素向右移动 k 个位置,其中 k 是非负数。 示例 1: ```js 输入: [1, 2, 3, 4, 5, 6, 7] 和 k = 3 输出: [5, 6, 7, 1, 2, 3, 4] 解释: 向右旋转...

```js for (var i = 0; i< 10; i++) { setTimeout(() => { console.log(i); }, 1000) } ```