boa/builtins/undefined/
mod.rs

1//! This module implements the global `undefined` property.
2//!
3//! The global undefined property represents the primitive value undefined.
4//!
5//! More information:
6//!  - [MDN documentation][mdn]
7//!  - [ECMAScript reference][spec]
8//!
9//! [spec]: https://tc39.es/ecma262/#sec-undefined
10//! [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined
11
12use crate::{builtins::BuiltIn, property::Attribute, BoaProfiler, Context, JsValue};
13
14#[cfg(test)]
15mod tests;
16
17/// JavaScript global `undefined` property.
18#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
19pub(crate) struct Undefined;
20
21impl BuiltIn for Undefined {
22    const NAME: &'static str = "undefined";
23
24    fn attribute() -> Attribute {
25        Attribute::READONLY | Attribute::NON_ENUMERABLE | Attribute::PERMANENT
26    }
27
28    fn init(_: &mut Context) -> (&'static str, JsValue, Attribute) {
29        let _timer = BoaProfiler::global().start_event(Self::NAME, "init");
30
31        (Self::NAME, JsValue::undefined(), Self::attribute())
32    }
33}