General Object Question; always prints something no matter what!?


#1


All throughout the Objects lessons every time I make an object in the console/printscreen whatever it will print something. Same thing with arrays. I never told it to print anything to console, so I can only assume that's just how it works. But for example, in the code below it prints "24" to the console. Without quotes. Why, and why only that? Similar things happen with arrays.


// Our bob object again, but made using a constructor this time 
var bob = new Object();
bob.name = "Bob Smith";
bob.age = 30;
// Here is susan1, in literal notation
var susan1 = {
  name: "Susan Jordan",
  age: 24
};
// Make a new susan2 object, using a constructor instead
var susan2 = new Object();
susan2.name = "Susan Jordan";
susan2.age = 24;


#2

@demtemblem,

++++ why second display of last Item
+++++++++++++++++++++++++++++
It is the Javascript interpreter which is running in this course-environment,
it display's the last non-displayed action...

You will also encounter this, when you are doing a return-statement
as last action...
You could counter this by using a
console.log( " " ); as last statement....

In some sections of this course, the course-checker Display's data
this you could then identify by placing two EXTRA code-line's:
console.log( "== My End ==" );
console.log( "== All that is displayed now, is the course-checker ==" );


#3

So basically it's just the way they have it set up for themselves on this website? That's not a thing javascript does on it's own? Like if I were coding this phenomenon is not something I'd have to deal with outside of code academy?


#4

hi try this it worked for me

// Our bob object again, but made using a constructor this time 
var bob = new Object();
bob.name = "Bob Smith";
bob.age = 30;
// Here is susan1, in literal notation
var susan1 = {
  name: "Susan Jordan",
  age: 24
};
// Make a new susan2 object, using a constructor instead
var susan2 = new Object();
susan2.age = 24;
susan2.name = "Susan Jordan";

#5

@demtemblem,
It will Always depend on the environment in which you are ....
Be aware that with Javascript you are using an Interpreted language
which is integrated into a Browser
and each Browser has its own specifics....!!!!!! and flaws....


#6

That solves that. Thanks!


#7

@demtemblem

Reference

google search
== the Book ==
javascript [your question] site:developer.mozilla.org

== discussions / opinions ==
javascript [your question] site:stackoverflow.com

== guidance ==
www.crockford.com
http://javascript.crockford.com/code.html <---JavaScript code-convention
http://javascript.crockford.com/survey.html
https://developer.mozilla.org/en-US/docs/Web/JavaScript/A_re-introduction_to_JavaScript
www.developer.mozilla.org/en-US/docs/Web/JavaScript/Guide
http://stackoverflow.com/questions/9549780/what-does-this-symbol-mean-in-javascript
http://stackoverflow.com/questions/3755606/what-does-the-exclamation-mark-do-before-the-function
http://stackoverflow.com/questions/6260475/how-to-the-operator
http://stackoverflow.com/questions/336859/var-functionname-function-vs-function-functionname?rq=1


#8

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.