@ngdoc method
@name $rootScope.Scope#$new
@kind function

@description
Creates a new child {@link ng.$rootScope.Scope scope}.

The parent scope will propagate the {@link ng.$rootScope.Scope#$digest $digest()} event.
The scope can be removed from the scope hierarchy using {@link ng.$rootScope.Scope#$destroy $destroy()}.

{@link ng.$rootScope.Scope#$destroy $destroy()} must be called on a scope when it is
desired for the scope and its child scopes to be permanently detached from the parent and
thus stop participating in model change detection and listener notification by invoking.

@param {boolean} isolate If true, then the scope does not prototypically inherit from the
parent scope. The scope is isolated, as it can not see parent scope properties.
When creating widgets, it is useful for the widget to not accidentally read parent
state.

@param {Scope} [parent=this] The {@link ng.$rootScope.Scope `Scope`} that will be the `$parent`
of the newly created scope. Defaults to `this` scope if not provided.
This is used when creating a transclude scope to correctly place it
in the scope hierarchy while maintaining the correct prototypical
inheritance.

@returns {Object} The newly created child scope.
function(isolate, parent) {
        var child;

        parent = parent || this;

        if (isolate) {
          child = new Scope();
          child.$root = this.$root;
        } else {
          // Only create a child scope class if somebody asks for one,
          // but cache it to allow the VM to optimize lookups.
          if (!this.$$ChildScope) {
            this.$$ChildScope = createChildScopeClass(this);
          }
          child = new this.$$ChildScope();
        }
        child.$parent = parent;
        child.$$prevSibling = parent.$$childTail;
        if (parent.$$childHead) {
          parent.$$childTail.$$nextSibling = child;
          parent.$$childTail = child;
        } else {
          parent.$$childHead = parent.$$childTail = child;
        }

        // When the new scope is not isolated or we inherit from `this`, and
        // the parent scope is destroyed, the property `$$destroyed` is inherited
        // prototypically. In all other cases, this property needs to be set
        // when the parent scope is destroyed.
        // The listener needs to be added after the parent is set
        if (isolate || parent !== this) child.$on('$destroy', destroyChildScope);

        return child;
      }