Web Analytics Made Easy -
StatCounter Printing the Java Script Object and JSON Object - CodingForum

Announcement

Collapse
No announcement yet.

Printing the Java Script Object and JSON Object

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Printing the Java Script Object and JSON Object

    Hello! I have some question about the way object are printed in mine case!

    In line 36 on the image of mine console and in line 46!
    They both printing the object value!
    But in line 56 there is JSON object printed with properties.. why in line 46 there was different print from line 56 ?
    What about java script object , can i print java script object in some way like in line 56 with all his properties?
    Code:
    $("#register-button").click(function () {
    
        var userInput = {
    
            user: {
    
                firstName: $("#first-name").val(),
                lastName: $("#last-name").val(),
                nickName: $("#nick_name").val(),
                email: $("#email_").val(),
                password: $("#password_").val(),
                customerType: $("#cust-type").val()
    
            }
        }
    
        var result = "";
    
        $.each(userInput,function (index,value) {
    
            result += "firstn: "+value.firstName+"</br>";
            result += "lastn: "+value.lastName+"</br>";
            result += "nickn: "+value.nickName+"</br>";
            result += "email: "+value.email+"</br>";
            result += "password: "+value.password+"</br>";
            result += "type: " +value.customerType+"</br>"+"</br>";
        });
    
        $("#form").hide();
    
        $("#container").html(result);
    
        console.log("Printing JAVASCRIPT Object "+userInput);
    
        var JsonString = JSON.stringify(userInput);
    
        console.log("Printing JSON String Format "+JsonString);
    
    
    
        var JsonObject = JSON.parse(JsonString);
    
        console.log("Printing JSON Object "+JsonObject);
    
        console.log(JsonObject);
    });
    Click image for larger version

Name:	Screenshot from 2016-09-24 04:39:03.png
Views:	1
Size:	26.8 KB
ID:	2283622
Working...
X