1

I found below JavaScript code snippet in adsense's developers.google.com site which allows me to inject external JS file into an iFrame when added few other parameters.

    (function(g,o){g[o]=g[o]||function(){(g[o]['q']=g[o]['q']||[]).push(
  arguments)},g[o]['t']=1*new Date})(window,'_googCsa');

When I tried to use above snippet in a Typescript file it gives me an error(shown in the picture down below). I tried fixing it but nothing was successful. enter image description here

Please help me fix this code snippet. I would like to use that snippet in an angular app component.

1 Answer 1

1

Typescript has a problem with using multiplication on a date. In this code, multiplication is being used to implicitly coerce the Date to a number. However, you can just accomplish the same thing explicitly.

(new Date).valueOf()
Sign up to request clarification or add additional context in comments.

2 Comments

It worked. Is there any documentation that I can follow to know all this?
There is a lot of documentation about a lot of things in a lot of places. Here's some documentation for .valueOf(). developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/…

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.