Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.7k views
in Technique[技术] by (71.8m points)

lodash.isArguments

arguments.js
image.png
1.为啥这里要==,而不是===
2.为啥要判断是不是isObjectLike,可以举例除了类对象,哪里还能得到arguments吗
arguments.test.js
image.png
摘抄自lodash

var args = toArgs([1, 2, 3]),
strictArgs = (function() { 'use strict'; return arguments; }(1, 2, 3))
function toArgs(array) {
  return (function() { return arguments; }.apply(undefined, array));
}

1.为啥要这么写,区分严格模式和非严格模式,不都是arguments吗
2.为啥要传入123

function() { return arguments; }()

有参无参应该都一样吧这应该都一样吧
3.

realm = {}
if (realm.arguments) {
      assert.strictEqual(isArguments(realm.arguments), true);
    }

realm什么情况会有 arguments属性
4.干嘛要比较这个

var falsey = [, null, undefined, false, 0, NaN, ''];
stubFalse = function() { return false; };
var expected = lodashStable.map(falsey, stubFalse);

 var actual = lodashStable.map(falsey, function(value, index) {
   return index ? isArguments(value) : isArguments();
 });

 assert.deepStrictEqual(actual, expected);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...