It is possible to model the logic of an application as a Petri Net even if you already encoded the application logic in a programming language. It is also possible to create a computer program (e.g. JavaScript) based on a Petri Net model of the application logic.
One way to model an application program as a Petri Net would be to consider the variables of the program as marks of places, weights of inputs or weights of outputs; and computations as logic annotations of inputs, outputs and transitions.
Roland Weber asked a very good question "which states of your program are important enough to become part of the model?" If you consider every variable and every computation as important then you might end up with a model that is too large for this exercise. Thus consider a part of the application program that is small enough for this exercise.
"A Petri Net Model for the Euclidean Algorithm" explains the relations between the variables of a function for the greatest commond divisor with the elements of a Petri Net using a dynamic and interactive diagram and discusses the various annotations associated with the Petri Net model.