public override Constant GetProperty(Constant key, Scope scope) { if (key is Number n) { return(Get((int)n.Value)); } var keyString = key.ToString(); int index; if (int.TryParse(keyString, out index)) { return(Get(index)); } if (keyString == "length") { return(new Number(List.Count)); } if (ArrayObject == null) { ArrayObject = Tool.Construct("Array", scope); } return(ArrayObject.Get(keyString)); }
public static Dictionary <string, object> ObjectToJson(Javascript.Object obj, Scope scope) { var json = new Dictionary <string, object>(); foreach (var key in obj.GetKeys()) { json[key] = ValueToJson(obj.Get(key), scope); } return(json); }
public Constant Get(string name) { Constant value = null; if (Properties.TryGetValue(name, ref value)) { return(value); } if (__proto__ != null) { return(__proto__.Get(name)); } return(Static.Undefined); }
public static bool IsType(Javascript.Object obj, Javascript.Object prototype) { return(obj.__proto__ == prototype.Get <Javascript.Object>("prototype")); }