devric
devric

Reputation: 3665

js, log object is different to log 'string' + obj

I'm logging a jQuery object, which assigns to

eg: $obj = <div></div>

if I

 log $obj

I get ''

 <div></div> 

, which is what I need. But when I

 Log 'some string' + $obj

I get this

  [ object, object]

which is not what I want. How do I get the normal log

Upvotes: 0

Views: 80

Answers (1)

icktoofay
icktoofay

Reputation: 129001

Don't use +; that will convert both to strings, giving you an unhelpful representation. Instead, pass two arguments into console.log:

console.log('a string', $obj);

Upvotes: 3

Related Questions