0

I am trying to find the reference on how to declare typed variables in JavaScript. I know I've seen it somwhere, but I cannot find any reference for it, nor can I remember the "correct" term for it. e.g.:

var name: string = "Ian Boyd";
  • I don't know if I saw it on the IEBlog, and it was in the works for the next version of Javascript
  • I don't know if it's something only available in "use strict" mode
  • I don't know if it's something that's been available for a while

All I know is that I saw it; and I'm not crazy.

1 Answer 1

5

No, that syntax doesn't exist in pure JavaScript. JavaScript is a loosely-typed language, even in ECMAScript 5 strict mode.

You may have seen it in ActionScript, a relative of JavaScript used in Flash scripting:

var someVariable:TypeName = someValue;

function someFunc():ReturnType {
}

// etc.

is all valid in ActionScript. ActionScript also has classes.

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.