Javascript examples for Object:Object Method
create a map without hardcoding the class name Map
<html> <head> <meta name="viewport" content="width=device-width"> </head> <body> <script> function createClass(arg) {//from w w w . jav a 2s.co m if(arg.isArray){ return []; } if(arg.has){ return new Map(); } return Object.create(Object.getPrototypeOf(arg)); } console.log(createClass({})); </script> </body> </html>