JsNull.cs 744 B

123456789101112131415161718192021222324252627282930313233343536
  1. using Jint.Runtime;
  2. namespace Jint.Native
  3. {
  4. public sealed class JsNull : JsValue, IEquatable<JsNull>
  5. {
  6. internal JsNull() : base(Types.Null)
  7. {
  8. }
  9. public override object ToObject()
  10. {
  11. return null!;
  12. }
  13. public override string ToString()
  14. {
  15. return "null";
  16. }
  17. public override bool IsLooselyEqual(JsValue value)
  18. {
  19. return ReferenceEquals(Null, value) || ReferenceEquals(Undefined, value);
  20. }
  21. public override bool Equals(JsValue? obj)
  22. {
  23. return Equals(obj as JsNull);
  24. }
  25. public bool Equals(JsNull? other)
  26. {
  27. return other is not null;
  28. }
  29. }
  30. }