code: public static void defineProperty(Scriptable destination,
                                        String propertyName, Object value,
                                        int attributes)
      {
          if (!(destination instanceof ScriptableObject)) {
              destination.put(propertyName, destination, value);
              return;
          }
          ScriptableObject so = (ScriptableObject)destination;
          so.defineProperty(propertyName, value, attributes);
      }
docs: Utility method to add properties to arbitrary Scriptable object.
  If destination is instance of ScriptableObject, calls
  defineProperty there, otherwise calls put in destination
  ignoring attributes
  @param destination ScriptableObject to define the property on
  @param propertyName the name of the property to define.
  @param value the initial value of the property
  @param attributes the attributes of the JavaScript property