0

What is the difference between this two type definitions?

type objectArray = [object]

type objectArray = object[]
1
  • 1
    The first is a tuple, second is array type. Commented Nov 8, 2022 at 23:04

1 Answer 1

1

[object] is a tuple. It's the type of an array with a single value in it, and the value must be an object.

object[] is the same as Array<object>. It's the type of an array with any number of values, where any such values must be object.

All tuples are arrays, but a tuple is a more restrictive type of array, with a specified number of elements.

Sign up to request clarification or add additional context in comments.

Comments

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.