public static EcmaValue Pop([This] EcmaValue thisValue) { RuntimeObject obj = thisValue.ToObject(); if (obj is EcmaArray arr && !arr.FallbackMode) { return(arr.Pop()); } long len = obj.Get(WellKnownProperty.Length).ToLength(); if (len == 0) { obj.SetOrThrow(WellKnownProperty.Length, 0); return(default);
public static EcmaValue Of([This] EcmaValue thisValue, params EcmaValue[] elements) { if (!thisValue.IsCallable || !thisValue.ToObject().IsConstructor) { return(new EcmaArray(elements)); } RuntimeObject arr = thisValue.Construct(elements.Length).ToObject(); for (long i = 0, len = elements.Length; i < len; i++) { arr.CreateDataPropertyOrThrow(i, elements[i]); } arr.SetOrThrow(WellKnownProperty.Length, elements.Length); return(arr); }