---
title: "Comment by Николай Коваленко on \"JavaScript Tips and Best Practices\" | Hashnode"
description: "if ([1, &#39;one&#39;, 2, &#39;two&#39;].includes(value)) { } It creates new array every time. It is slower than multiple values comparison"
url: "https://hashnode.com/posts/javascript-tips-and-best-practices/60e17cd303707d644a5022e6/comment/60e2130b4f8e376422a7aa85"
---

[Discussion](https://hashnode.com/posts/javascript-tips-and-best-practices/60e17cd303707d644a5022e6)

Comment [JavaScript Tips and Best Practices](https://hashnode.com/posts/javascript-tips-and-best-practices/60e17cd303707d644a5022e6)

[Николай Коваленко](https://hashnode.com/@Nikolai)

[Jul 4, 2021](https://hashnode.com/posts/javascript-tips-and-best-practices/60e17cd303707d644a5022e6/comment/60e2130b4f8e376422a7aa85)

if (\[1, 'one', 2, 'two'\].includes(value)) {

}

It creates new array every time. It is slower than multiple values comparison

[Apoorv Tyagi](https://hashnode.com/@apoorvtyagi)

[Jul 5, 2021](https://hashnode.com/posts/javascript-tips-and-best-practices/60e17cd303707d644a5022e6/comment/60e2130b4f8e376422a7aa85#reply-60e2ffb403707d644a504faf)

Would love to learn more about it. Do you have any links or resource

[Николай Коваленко](https://hashnode.com/@Nikolai)

[Jul 5, 2021](https://hashnode.com/posts/javascript-tips-and-best-practices/60e17cd303707d644a5022e6/comment/60e2130b4f8e376422a7aa85#reply-60e318a94f8e376422a7c532)

[Apoorv Tyagi](https://hashnode.com/@apoorvtyagi) make a loop of 1000 and compare durations

[Николай Коваленко](https://hashnode.com/@Nikolai)

[Jul 5, 2021](https://hashnode.com/posts/javascript-tips-and-best-practices/60e17cd303707d644a5022e6/comment/60e2130b4f8e376422a7aa85#reply-60e31aa94f8e376422a7c55d)

[Apoorv Tyagi](https://hashnode.com/@apoorvtyagi)

const value = 1; const start = performance.now(); for(let i = 0; i<100000; i++) { if (\[1, 'one', 2, 'two'\].includes(value)) {

} }

console.log(performance.now() - start);

const start2 = performance.now(); for(let i = 0; i<100000; i++) { if (value === 1 || value === 'one' || value === 2 || value === 'two') {

} }

console.log(performance.now() - start2);

Second is 2 times faster

[Apoorv Tyagi](https://hashnode.com/@apoorvtyagi)

[Jul 6, 2021](https://hashnode.com/posts/javascript-tips-and-best-practices/60e17cd303707d644a5022e6/comment/60e2130b4f8e376422a7aa85#reply-60e3c6f94aacd630482416f2)

Thanks [Николай Коваленко](https://hashnode.com/@Nikolai) I Will check this.
