---
title: "If or - shorter way"  
description: "If or - shorter way"  
author: "Samuel Fernandes"  
published: 2013-06-06  
updated: 2013-06-06  
canonical: https://www.mindstick.com/forum/1001/if-or-shorter-way  
category: "javascript"  
tags: ["javascript"]  
reading_time: 1 minute  

---

# If or - shorter way

Hi Everyone,\
I have many or inside if\
**if (n==0 || n==1 || n==2 || n==37 || n==5 ...)** Is there a shorter way, something like\
**if (n==(0,1,2,37,5...))** **\**Thanks in advance.

## Replies

### Reply by AVADHESH PATEL

Hi,\
You can try as following\
**if([0,1,2,37,5].indexOf(n) != -1)****\**I hope it helpful for you.\


---

Original Source: https://www.mindstick.com/forum/1001/if-or-shorter-way

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
