public WeakSetInstance Construct(object iterable)
        {
            // Create a new set.
            var result = new WeakSetInstance(this.InstancePrototype);

            // If iterable is not null or undefined, then iterate through the values and add them to the set.
            if (iterable != Undefined.Value && iterable != Null.Value)
            {
                var iterator = TypeUtilities.RequireIterator(Engine, iterable);

                // Get a reference to the add function.
                var addFunc = result["add"] as FunctionInstance;
                if (addFunc == null)
                {
                    throw new JavaScriptException(ErrorType.TypeError, "Missing 'add' function.");
                }

                // Call the add function for each value.
                foreach (var value in TypeUtilities.Iterate(Engine, iterator))
                {
                    addFunc.Call(result, value);
                }
            }

            return(result);
        }
        public WeakSetInstance Construct(object iterable)
        {
            // Create a new set.
            var result = new WeakSetInstance(this.InstancePrototype);

            // If iterable is not null or undefined, then iterate through the values and add them to the set.
            if (iterable != Undefined.Value && iterable != Null.Value)
            {
                var iterator = TypeUtilities.GetIterator(Engine, TypeConverter.ToObject(Engine, iterable));
                if (iterator != null)
                {
                    // Get a reference to the add function.
                    var addFunc = result["add"] as FunctionInstance;
                    if (addFunc == null)
                        throw new JavaScriptException(Engine, ErrorType.TypeError, "Missing 'add' function.");

                    // Call the add function for each value.
                    foreach (var value in TypeUtilities.Iterate(Engine, iterator))
                    {
                        addFunc.Call(result, value);
                    }
                }
            }

            return result;
        }
        //     INITIALIZATION
        //_________________________________________________________________________________________

        /// <summary>
        /// Creates a new WeakSet constructor.
        /// </summary>
        /// <param name="prototype"> The next object in the prototype chain. </param>
        internal WeakSetConstructor(ObjectInstance prototype)
            : base(prototype, __STUB__Construct, __STUB__Call)
        {
            // Initialize the constructor properties.
            var properties = new List <PropertyNameAndValue>();

            InitializeConstructorProperties(properties, "WeakSet", 0, WeakSetInstance.CreatePrototype(Engine, this));
            InitializeProperties(properties);
        }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="weakSetInstance">The displayed WeakSetInstance</param>
 internal WeakSetInstanceDebugView(WeakSetInstance weakSetInstance)
 {
     this.weakSetInstance = weakSetInstance;
 }