JsNull.cs 777 B

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