I would put
whether in a .php file or a snippet or TV.
Now if I’m trying to get the ID of the current page, it would depend on where I was. Usually you can use
or if within some php code,
$modx->documentIdentifier
Usually a string (such as the output for a snippet) is initialized like this:
Have you been working with javascript code lately