"define" in javascript ?

is there a way to do something like

#define PLAYERPOS player.transform.position

in javascript, so that it replaces "PLAYERPOS" with "player.transform.position" at compile time (like in c++) ?

that could really help to keep my code less complex

Player isn't accessible at compile time, neither is transform, nor position from that

You could make a variable called playerTrans which refers to player.transform, but that's the best you're going to get

Edit for the fun of it:

class YourFileName extends MonoBehaviour //the below doesn't work without doing the class explicitly
    function get PlayerPos() { return player.transform.position; }

Then you use it like this:

var test = PlayerPos;

There are cases where macros are useful but mostly they are just evil, in this case you would be better served by a function in any language: "Why should I use inline functions instead of plain old #define macros?"

Something like this:

function GetPosition(component : MonoBehaviour) : Vector3
    return component.transform.position;