Description: The adapter mode looks like a façade mode on the surface. They all have to wrap other objects and change the interfaces they render. But the difference is how they change the interface. Façade elements represent a simplified interface that does not provide an additional choice, and sometimes it makes some assumptions in order to facilitate common tasks. Instead, the adapter converts an interface to another interface, which does not filter out certain functions or simplifies the interface .
Scenario: Interfaces that are intended for customer systems are incompatible with interfaces provided by existing APIs. It can only be used to coordinate grammatical differences. The two methods the adapter should perform should be a similar task, otherwise it will not solve the problem.
Example: If you have a function with 3 string arguments, but the client system has an array of three string elements, you can use an adapter to connect the two.
// String Object var clientobj = { str1:"foo", str2:"Bar", str3:"Baz"}; // interface Functions function Interfacefn (STR1,STR2,STR3) { //... .. }// adapter functions function clienttointerfaceadapter (o) { interfacefn (O.STR1,O.STR2,O.STR3);}
JS design mode-Adapter mode