diff --git a/lib/internal/navigator.js b/lib/internal/navigator.js index 546505e9460103..e56b2da5e339e3 100644 --- a/lib/internal/navigator.js +++ b/lib/internal/navigator.js @@ -78,10 +78,10 @@ function getNavigatorPlatform(process) { class Navigator { // Private properties are used to avoid brand validations. #availableParallelism; - #userAgent = `Node.js/${StringPrototypeSlice(nodeVersion, 1, StringPrototypeIndexOf(nodeVersion, '.'))}`; - #platform = getNavigatorPlatform(process); - #language = Intl?.Collator().resolvedOptions().locale || 'en-US'; - #languages = ObjectFreeze([this.#language]); + #userAgent; + #platform; + #language; + #languages; constructor() { if (arguments[0] === kInitialize) { @@ -102,6 +102,7 @@ class Navigator { * @return {string} */ get language() { + this.#language ??= Intl?.Collator().resolvedOptions().locale || 'en-US'; return this.#language; } @@ -109,6 +110,7 @@ class Navigator { * @return {Array} */ get languages() { + this.#languages ??= ObjectFreeze([this.language]); return this.#languages; } @@ -116,6 +118,7 @@ class Navigator { * @return {string} */ get userAgent() { + this.#userAgent ??= `Node.js/${StringPrototypeSlice(nodeVersion, 1, StringPrototypeIndexOf(nodeVersion, '.'))}`; return this.#userAgent; } @@ -123,6 +126,7 @@ class Navigator { * @return {string} */ get platform() { + this.#platform ??= getNavigatorPlatform(process); return this.#platform; } }