Question: In Javascript, is there a way to achieve something similar to this ?

```
const databaseObjectID = "someId"; // like "product/217637"

switch(databaseObjectID) {
    case includes('product'): actionOnProduct(databaseObjectID); break;
    case includes('user'): actionOnUser(databaseObjectID); break;
    // .. a long list of different object types
}

```

This is more a curiosity question to understand the possibilities of switch / case, as in this particular case I have solved my problem using `const type = databaseObjectID.split('/')[0];` and apply the switch case on `type`

Answer: 
You usage would be considered an abuse of case.

Instead just use ifs 

```
     if (databaseObjectId.includes('product')) actionOnProduct(databaseObjectID); 
else if (databaseObjectId.includes('user'))    actionOnUser(databaseObjectID); 
// .. a long list of different object types

```

If the ObjectId contains static content around the product or user, you can remove it and use the user or product as a key:

```
var actions = {
  "product":actionOnProduct,
  "user"   :actionOnUser
}

actions[databaseObjectId.replace(/..../,"")](databaseObjectId);

```
Sorry, I'm a noob so someone will probably have to clean this up, but here is the idea. Pass to a function to check and return a category then use the switch.

```
function classify(string){
  var category = categorize(string);
  switch (category) {
    case 'product':
      console.log('this is a product');
      break;
    case 'user':
      console.log('this is a user');
      break;
    default:
      console.log('category undefined');    
  }
}

function categorize(string){
  if (string.includes('product')){
    return 'product';
  }
  if (string.includes('user')){
    return 'user';
  }
}

classify("product789");
classify("user123");
classify("test567");

```

Sorry, as well, for not matching your example.