'How would I see if a specific item is on a list in JavaScript? [duplicate]

I have a list called usernames, that stores usernames. I want to see if the specific username is on the list and deny the person if it is. Code:

var usernames = ["someuser",""];

io.on('connection', function(socket){

  socket.on("join", function(room, username == usernames){
    if (username != "" || username == usernames){
   // do something
    }
  })


Solution 1:[1]

Looks like you may need to specify the character encoding, according to this SO answer. Java version:

MvcResult result = mvc.perform(post("/administration")
    .contentType(MediaType.APPLICATION_JSON)
    .content(json)
    .characterEncoding("utf-8"))
    .andExpect(status().isOk())
    .andReturn();

I'll edit this post if you need the Kotlin DSL version.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Gabriel Pizarro