JavaScript: implementare il metodo isEmptyObject() di jQuery

In questo articolo vedremo come implementare il metodo isEmptyObject() di jQuery in JavaScript.

JavaScript di Gabriele Romanato

In questo articolo vedremo come implementare il metodo isEmptyObject() di jQuery in JavaScript.

La soluzione รจ la seguente:


'use strict';

const isEmptyObject = obj => {
    if(typeof obj !== 'object' || obj === null) {
        return false;
    }
    return JSON.stringify(obj) === '{}';
};

Commenti