i looking way javascript read in string.
for example, take following code.
var object = { myfunction: function() { console.log("function!"); } }
i way of getting code string, line breaks , all. comes down user.
i haven't found similar questions on investigations, , i've been looking few hours.
edit
note, didn't specify serialisation of object. specified serialisation of code.
var n = 1; var x = "hello"; var = "hi";
how can string, object declaration?
var object = { func1: function() { console.log("function!"); }, func2: function(s) { console.log(s); }, func3: function(s) { console.log(s); }, str1: 'string 1', str2: 'string 2', obj1: { a:'string a' } } var $console = $('#console'); for(item in object){ if(typeof object[item] == 'object') { $console.html( $console.html() +"\r\n"+ 'type of ' + item+':' + typeof object[item]); for(objitem in object[item]){ $console.html( $console.html() +"\r\n"+ 'type of ' + item+':'+ object[item][objitem] +': '+ typeof object[item][objitem]); $console.html( $console.html() +"\r\n"+ object[item][objitem].tostring() ); } } else { $console.html( $console.html() +"\r\n"+ 'type of ' + item +': '+ typeof object[item]); $console.html( $console.html() +"\r\n"+ object[item].tostring() ); } }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script> <pre id="console"></pre>
seems couldn't find this in investigation.
Comments
Post a Comment