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
254 views
in Technique[技术] by (71.8m points)

javascript - “!-”在JavaScript中有什么作用?(What does “!--” do in JavaScript?)

I have this piece of code (taken from this question ):

(我有这段代码(取自这个问题 ):)

var walk = function(dir, done) {
    var results = [];

    fs.readdir(dir, function(err, list) {
        if (err)
            return done(err);

        var pending = list.length;

        if (!pending) 
            return done(null, results);

        list.forEach(function(file) {
            file = path.resolve(dir, file);
            fs.stat(file, function(err, stat) {
                if (stat && stat.isDirectory()) {
                    walk(file, function(err, res) {
                        results = results.concat(res);

                        if (!--pending)
                            done(null, results);
                    });
                } else {
                    results.push(file);

                    if (!--pending) 
                        done(null, results);
                }
            });
        });
    });
};

I'm trying to follow it, and I think I understand everything except for near the end where it says !--pending .

(我正在尝试遵循它,我想我了解所有内容,除了它说的末尾!--pending)

In this context, what does that command do?

(在这种情况下,该命令有什么作用?)

Edit: I appreciate all the further comments, but the question has been answered many times.

(编辑:我感谢所有进一步的评论,但问题已得到解答很多次。)

Thanks anyway!

(不管怎么说,还是要谢谢你!)

  ask by Kieran E translate from so

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

Please log in or register to answer this question.

Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...