jerryscript-project / jerryscript

Ultra-lightweight JavaScript engine for the Internet of Things.
https://jerryscript.net
Apache License 2.0
6.95k stars 673 forks source link

A question about this #3661

Closed YiWen-y closed 4 years ago

YiWen-y commented 4 years ago

When printing this, most engines output [object global], such as v8, spiderMonkey, chakra, etc., but the output of jerry is [object Object]. Why does it happen?

JerryScript revision

996bf76

Build platform
Ubuntu 16.04.6 LTS (Linux 4.15.0-55-generic x86_64)
Build steps
python tools/build.py --clean --debug --logging=on --line-info=on --error-messages=on --cpointer-32bit=on --mem-heap=1572864 --profile=es2015-subset
Test case
var f = function() {
    print(this);
};
f();
Execution steps
build/bin/jerry testcase.js
Output
 [object Object]
Expected behavior
 [object global]
rerobika commented 4 years ago

Hi @YiWen-y,

The console.log/print like functions are engine specific and the standard does not contain any point about them, so I would not say that this is the expected behavior only other engines creates different output.

rerobika commented 4 years ago

The issue seems resolved, closing it.