0

I am inspecting some code on Github and I need to quickly understand if the script is javascript or typescript.

Are there any easy shortcuts or clues to this?

As an example, in this image from https://www.typescriptlang.org/ gives me a clue that if an array is declared with a bracket [] after the variable name, then it is typescript.

enter image description here

2
  • Read the file name .js => .ts Commented Mar 23, 2020 at 0:34
  • thanks, how about Javascript, is it Javascript if the extension is .js ? Commented Mar 23, 2020 at 0:36

1 Answer 1

1

You can distinguish between the two formats by looking simply at the functions.

Are any of the functions specifying types such as 'string,integer,object,array,function?...' etc?

In traditionally javascript this is not allowed.

Best, AT

Also as others may have pointed out, you can also check the file extension

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

2 Comments

so in contemporary javascript 'string,integer,object,array,function?...' is allowed?
They are but the language is not explicity typed. They are implicitly referred to by the contents or by other means. On the right hand side you may see new Arrays() or whatever but on the left side (assignment) there will be no declared type. The variable just get what it asks for

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.