Is there a Javascript function similar to the Python Counter function?

前端 未结 6 2203
逝去的感伤
逝去的感伤 2021-02-19 01:17

I am attempting to change a program of mine from Python to Javascript and I was wondering if there was a JS function like the Counter function from the collections module in Pyt

6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-19 02:14

    There is also pycollections.js, which works on Node and in client-side JS.

    Example:

    var collections = require('pycollections');
    var counter = new collections.Counter([true, true, 'true', 1, 1, 1]);
    counter.mostCommon(); // logs [[1, 3], [true, 2], ['true', 1]] 
    

提交回复
热议问题