I'm relatively new to JS and i have come across this scenario, where i need to identify if a method defined in a JS object follows a particular interface.

Let me explain with the help of an example:

```
let logger1 = {
    log: function(message, meta){
        //logging functionality
    }
};

let logger2 = {
    log: function(level, message, meta){
        //logging functionality
    }
}

```

There are 2 logger objects (logger1 or logger2), which has its own logging functionalities. They can get passed from the client to a library, that the client consumes.   
Library expects the log method to be of a particular interface, which is already mentioned in the library documentation. Inside the library, how would we verify if the logger object passed in has the 'log' method that matches the interface, the library is expecting ?

```
let Library = function(logger){
    //Here I can verify if the 'log' function is defined. But how do i make sure the log 
    //function matches the interface that the library is expecting ?     
    //Let's say the interface that the library is expecting is function(level,message,meta),
    //which is satisfied only by logger2.
    if(logger && typeof(logger.log) === 'function'){
        this.logger = logger;
    }
    else{
        this.logger = console;
    }
}

let lib1 = new Library(logger1);
let lib2 = new Library(logger2);

```