Empty array and ternary operator

I am sorry if this is a dumb question but
'' ? console.log('Product found') : console.log('Product not found')
This statement is correctly evaluated (empty string). But
[] ? console.log('Product found') : console.log('Product not found')
Why does the the above sentence throw an error? Since empty array is truthy I was expecting first condition to run

I’m getting 'Product found' though… What kind of error are you getting?

This is what I’m getting

[] ? console.log('product found') : console.log('Product not found')
 ^

SyntaxError: Unexpected token ]
    at new Script (vm.js:79:7)
    at createScript (vm.js:251:10)
    at Object.runInThisContext (vm.js:303:10)
    at Module._compile (internal/modules/cjs/loader.js:657:28)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
    at startup (internal/bootstrap/node.js:283:19)

Hmm… Do you have both of those lines next to each other, but no semicolon? I’m getting the same error when I do that.

'' ? console.log('Product found') : console.log('Not found!!!')
[] ? console.log('Product found') : console.log('Not found!!!')

Adding semicolons at the end of each lines should fix that then.

No I don’t. But I just ran this command on browser console and it didn’t throw any error. I guess it must be related to nodejs

What’s the rest of the code, and where are you trying to run it? Because it works fine in a Node environment as well