Skip to content
On this page

getResult(): IResult

Get all information regarding browser, CPU, device, engine, & OS from user-agent string.

js
// Result object is structured as follow:
{ 
    ua: "", 
    browser: { 
        name: "", 
        version: "",
        major: ""
    }, 
    cpu: {
        architecture: ""
    }, 
    device: {
        type: "",
        vendor: "",
        model: ""
    }, 
    engine: {
        name: "",
        version: ""
    }, 
    os: {
        name: "",
        version: ""
    }
}

ua: string

The user-agent string value of current instance.

browser: IBrowser

Object that contains the value of browser name, full version, & major version.

cpu: ICPU

Object that contains the value of type of CPU architecture.

device: IDevice

Object that contains the value of device details: type, vendor, model.

engine: IEngine

Object that contains the value of layout rendering engine name & version.

os: IOS

Object that contains the value of operating system name & version.

Code Example

js
const galaxytabs8 = 'Mozilla/5.0 (Linux; Android 12; SM-X706B) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.53 Safari/537.36'
const parser = new UAParser(galaxytabs8);

console.log(parser.getResult());
/*
{ 
    ua: "Mozilla/5.0 (Linux; Android 12; SM-X706B) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.53 Safari/537.36", 
    browser: { 
        name: "Chrome", 
        version: "103.0.5060.53",
        major: "103"
    }, 
    cpu: {
        architecture: undefined
    }, 
    device: {
        type: "mobile",
        vendor: "Huawei",
        model: "SM-X706B"
    },
    engine: {
        name: "Blink",
        version: "103.0.5060.53"
    }, 
    os: {
        name: "Android",
        version: "12"
    }
}
*/

Licensed under the MIT License.