0
    const name = 'My name'
    const age = 25

    const detailsDynamic = {
        'Name': `${name}`,
        'Age': `{age}`
    }

    const detailsStatic = {
        'Name':'My name',
        'Age': 25
    }

    if(detailsDynamic == detailsStatic){
        console.log('Equal details')
    }else{
        console.log('Not equal details')
    }

Why this is not the same JSON while I console it looks the same, but condition fails always to 'Not equal details' Can someone help?

root
  • 11
  • 1
    There is no JSON here. – deceze Apr 21 '22 at 11:24
  • 2
    A JavaScript object (what you have) is not the same as JSON (which is a textual data exchange format). – Felix Kling Apr 21 '22 at 11:25
  • I have to send a post request with axios but I would read the post parameters from config, while I set the parameters hardcoded it works, but while I call it from config it does not works. However they looks same after console.log. One issue I think is that I Have created a class in nodejs and require('config') file and defined all configParams in constructor, I have a regular method say service() while would create another instance for this. So this.configs dont works in service() I have to make an instance of new class() then it call this.configParams. If this is the issue my axiosnotworking – root Apr 22 '22 at 06:44
  • You have seen the duplicate at the top…? – deceze Apr 22 '22 at 06:46

0 Answers0