Something Like that:
Whitespace
What is Whitespace?
Invisible characters that create literal ‘space’ in your written code
(carriage return, tabs, space)
basically Whitespace means clean code with comments for easy understand to coder
There are two examples and both are correct
For that you need to create first html code.
HTML
<p id="demo1"></p>
After that add this JS code.
JS
var firstname, lastname, lang; var person = {firstname: 'John', lastname: 'Doe'} document.getElementById("demo1").innerHTML = person;
[codepen_embed height=”265″ theme_id=”0″ slug_hash=”rzwOae” default_tab=”result” user=”pradeepanvi”]See the Pen Whitespace in javascript by Pradeep Kumar (@pradeepanvi) on CodePen.[/codepen_embed]
Now you can see
[object Object]
Now next example with clean code
For that you need to create first html code.
HTML
<p id="demo1"></p>
After that add this JS code.
JS
var // first name of the person firstname, // last name of the person lastname, // the lang // can be 'en' or 'es' lang; var person = { // the first name firstname: 'John', // the last name // (always required) lastname: 'Doe' } document.getElementById("demo1").innerHTML = person;
[codepen_embed height=”265″ theme_id=”0″ slug_hash=”dzRYXJ” default_tab=”result” user=”pradeepanvi”]See the Pen Whitespace in javascript 02 by Pradeep Kumar (@pradeepanvi) on CodePen.[/codepen_embed]
This is the best way to write code.
Now you can see
[object Object]