Lyubomir Velchev
Lyubomir Velchev

Reputation: 962

Typescript Window Setting Variable

I have part of typescript code

  var root = window['appPath'] 
  window.location.replace(root + '.... some url

Is the variable windows part of typescript? How do I assign it? Is it a key/value and what can I store in it? Thanks

Upvotes: 0

Views: 678

Answers (1)

basarat
basarat

Reputation: 275947

Is the variable windows part of typescript

Its a part of browser spec : http://www.w3schools.com/jsref/obj_window.asp

TypeScript defines these common globals for you in a file lib.d.ts : https://github.com/Microsoft/TypeScript/blob/master/bin/lib.d.ts

How do I assign it?

You shouldn't and actually browsers will not let you.

Is it a key/value and what can I store in it?

All JavaScript objects (I'm being lose here) act like key/value stores. The only allowed key is string. Value can be any other JavaScript object.

That said. DONT PUT STUFF ON WINDOW. MILLIONS OF KITTENS WILL DIE

Upvotes: 3

Related Questions