mde / ejs

Embedded JavaScript templates -- http://ejs.co
Apache License 2.0
7.71k stars 846 forks source link

Help with IF condition #630

Closed carlosac closed 2 years ago

carlosac commented 2 years ago

I have 2 arrays: <%= users[0].profile %><br/>

<%= profiles[1] %>

<% if (users[0].profile == profile[1]) { %> <h2>True</h2> <% } %> <p>tipeof : <%= typeof usuarios[0].profile %></p>

Result in my page:

{ _id: 6151c977a54e2513f093fda0, name: 'Suporte', codigoPerfil: 2, __v: 0 } { _id: 6151c977a54e2513f093fda0, name: 'Suporte', codigoPerfil: 2, __v: 0 } tipeof : object

Why the If condition is not true? I change to <% if (users[0].profile._id == profile[1]._id) { %> and not resolve.

Thanks for help

mde commented 2 years ago

I'm not sure what the question is. This does not seem specific to EJS. There is likely a problem in your application logic. You might try working with your code in pure JS first, to ensure things are working as you expect, before bringing in the templating.

I am closing this issue. If you can create a minimal failing test, that demonstrates a problem in EJS itself, feel free to reopen.