Code Monkey home page Code Monkey logo

Comments (7)

WangNianyi2001 avatar WangNianyi2001 commented on May 26, 2024 1

@shaunzeng Since you speak Chinese, why did you comment in English in the first time?

from underscore-analysis.

daijinma avatar daijinma commented on May 26, 2024
var isEven = function(num) {
  return !(num & 1);
};

这里面的 & 怎么理解?

from underscore-analysis.

lessfish avatar lessfish commented on May 26, 2024

@daijinma
& 位运算与,num & 1 相当于 num % 2
关于位运算,如果有兴趣可以看下我以前写的位运算系列文章 http://www.cnblogs.com/zichi/category/732474.html

from underscore-analysis.

shaunzeng avatar shaunzeng commented on May 26, 2024

hey, awesome article! really enjoyed learning from it!

I have a question, how is '.findIndex' not checking if it's an array or not? and how come '.sortedIndex' is not checking the obj type, but still make it work on objects?

By the way, I speak Chinese so you could response in Chinese. Really appreciate!

Thanks

from underscore-analysis.

lessfish avatar lessfish commented on May 26, 2024

@shaunzeng
For the first question, Underscore does not do any static type checking, I think it's better to throw an error when passing a para to '.findIndex' which is not an array.

For the second, maybe '.findIndex' and '.sortedIndex' are both working on arrays? not on objects for they're both Array Functions?

from underscore-analysis.

aleen42 avatar aleen42 commented on May 26, 2024

是不是因为它的二分查找并没有针对倒序的有序数组处理,因此不给予 isSorted 选项

from underscore-analysis.

Ocean5app avatar Ocean5app commented on May 26, 2024

cb(predicate, context) 中的cb方法是如何定义的?哪里能找到

from underscore-analysis.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.