async function myFoo (val) {
if (val > 1) {
val = await myFoo(val - 1)
}
return request('http://some.url/?v=' + val)
}
async function myBar () {
let r1 = await myFoo(5)
console.log( 'r1', r1 )
}
myBar()
function hueta() {
var obj = {test: {t1: 1, t2: 2}};
///////////////////
var test = obj.test;
console.log(test, test);
///////////////////
console.log(obj.test, obj.test)
}
hueta()
[generating bytecode for function: hueta]
Parameter count 1
Frame size 48
76 E> 0x1f2b750fd252 @ 0 : 91 StackCheck
93 S> 0x1f2b750fd253 @ 1 : 6c 00 01 08 f9 CreateObjectLiteral [0], [1], #8, r2
0x1f2b750fd258 @ 6 : 1f f9 fb Mov r2, r0
154 S> 0x1f2b750fd25b @ 9 : 20 f9 01 02 LdaNamedProperty r2, [1], [2]
0x1f2b750fd25f @ 13 : 1e fa Star r1
163 S> 0x1f2b750fd261 @ 15 : 0a 02 06 LdaGlobal [2], [6]
0x1f2b750fd264 @ 18 : 1e f8 Star r3
171 E> 0x1f2b750fd266 @ 20 : 20 f8 03 08 LdaNamedProperty r3, [3], [8]
0x1f2b750fd26a @ 24 : 1e f9 Star r2
171 E> 0x1f2b750fd26c @ 26 : 4d f9 f8 fa fa 04 CallProperty2 r2, r3, r1, r1, [4]
210 S> 0x1f2b750fd272 @ 32 : 0a 02 06 LdaGlobal [2], [6]
0x1f2b750fd275 @ 35 : 1e f8 Star r3
218 E> 0x1f2b750fd277 @ 37 : 20 f8 03 0c LdaNamedProperty r3, [3], [12]
0x1f2b750fd27b @ 41 : 1e f9 Star r2
226 E> 0x1f2b750fd27d @ 43 : 20 fb 01 0e LdaNamedProperty r0, [1], [14]
0x1f2b750fd281 @ 47 : 1e f7 Star r4
236 E> 0x1f2b750fd283 @ 49 : 20 fb 01 10 LdaNamedProperty r0, [1], [16]
0x1f2b750fd287 @ 53 : 1e f6 Star r5
218 E> 0x1f2b750fd289 @ 55 : 4d f9 f8 f7 f6 0a CallProperty2 r2, r3, r4, r5, [10]
0x1f2b750fd28f @ 61 : 04 LdaUndefined
242 S> 0x1f2b750fd290 @ 62 : 95 Return
const json = `{
"type": "widget-chart",
"title": "Handcrafted Wooden Sausages",
"data": {
"chart": {
"height": "100%",
"type": "donut"
},
"series": [
44,
55,
41,
17,
15
],
"responsive": [
{
"breakpoint": 480,
"options": {
"chart": {
"width": 200
},
"legend": {
"position": "bottom"
}
}
}
]
},
"_id": "5cf6307a245e2b001efd2111",
"id": "5cf6307a245e2b001efd2111"
}
`
console.time('eval')
let e = {}
eval('e = ' + json)
console.timeEnd('eval')
console.time('JSON.parse')
let p = {}
p = JSON.parse(json)
console.timeEnd('JSON.parse')
console.time('Function')
let f = {}
f = new Function('return ' + json)
console.timeEnd('Function')
<script id="data" type="application/json">{"org": 10, "items":.......
var data = JSON.parse(document.getElementById('data').innerHTML)