标签:text 参数 rom 覆盖 buffer new lob top https
decodeURIComponent(‘%E4%B8%AD‘)
https://cnodejs.org/topic/54745ac22804a0997d38b32d
http://koa.rednode.cn/
var s = new stream.Readable();
s._read = function noop() {}; // redundant? see update below
s.push(‘your text here‘);
s.push(null);
The key is to use these two Stream events:
Event: ‘data‘
Event: ‘end‘
For stream.on(‘data‘, ...) you should collect your data data into either a Buffer (if it is binary) or into a string.
For on(‘end‘, ...) you should call a callback with you completed buffer, or if you can inline it and use return using a Promises library.
http://stackoverflow.com/questions/1606797/use-of-apply-with-new-operator-is-this-possible
var f = new (Function.prototype.bind.apply(Function, [null, ‘a‘, ‘b‘, ‘return a*b‘]));
运行new Cls()时,参数数目是固定的。但是bind方法可以:
var f = Cls.bind(anything, arg1, arg2, ...);
result = new f();
anything是什么没关系,因为new操作重置了f的上下文。只是句法的需要。
现在,对于bind调用,我们要传入可变参数,那就这样:
var f = Cls.bind.apply(Cls, [anything, arg1, arg2, ...]);
result = new f();
Cls.bind是个bind函数,但是Cls.bind可能被覆盖。所以用Function.prototype.bind替换。
http://dfkaye.github.io/2014/03/14/javascript-eval-and-function-constructor/
eval执行代码是,作用域设在当前执行作用域,可以访问局部变量。
The eval function has access to the global scope, so it can clobber any globals as well. Function shares this problem.
eval可以访问全局作用域,所以它能狠揍(哈哈)任何全局变量。Function不存在这个问题。
new Function不能访问当前作用域。可以访问全局。
new Function是都会修改全局的。狠揍的意思是定义变量不写var前缀。
eval是,如果当前中有,则修改当前的。如果没有则狠揍全局的。
标签:text 参数 rom 覆盖 buffer new lob top https
原文地址:http://www.cnblogs.com/thus/p/6323589.html