1

in Node.js, process.hrtime is Object like that

hrtime: { [Function: hrtime] bigint: [Function] }, (in pcoress object)

hrtime can be executed by process.hrtime() and has key bigint as a function that executed by process.hrtime.bigint().

i wonder how it possible hrtime is a function and object at the same time.

i tried to include anonymous function in object, but failed.

how can i make it?

process {
  title: 'node',
  version: 'v10.16.3',
...
  hrtime: { [Function: hrtime] bigint: [Function] },
...
}

1 Answer 1

2

You can assign properties on functions like you can onto any object.

function x() {
  console.log("You have successfully called x()!");
}

function y() {
  console.log("Hello, this is y()!");
}

x.y = y;

x();
x.y();

prints out

You have successfully called x()!
Hello, this is y()!
Sign up to request clarification or add additional context in comments.

1 Comment

thank you! Not "anonymous function in object" but "property of function" !

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.