---
title: "createExpression | JavaScript maps SDK"
description: "Documentation for MapTiler SDK"
---

> For AI agents: a documentation index is available at [/llms.txt](https://docs.maptiler.com/llms.txt). Markdown versions of all pages are available by appending .md to any URL.

# Function createExpression

-   createExpression(  
        expression: unknown,  
        propertySpec?: [StylePropertySpecification](https://docs.maptiler.com/sdk-js/api-reference/types/StylePropertySpecification/) | null,  
        globalState?: [Record](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.Record/)<string, any\>,  
    ): [Result](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.Result/)<[StyleExpression](https://docs.maptiler.com/sdk-js/api-reference/classes/StyleExpression/), [ExpressionParsingError](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.ExpressionParsingError/)\[\]\>[](#createexpression)
    
    Parse and typecheck the given style spec JSON expression. If options.defaultValue is provided, then the resulting StyleExpression's `evaluate()` method will handle errors by logging a warning (once per message) and returning the default value. Otherwise, it will throw evaluation errors.
    
    #### Parameters
    
    -   expression: unknown
    -   `Optional`propertySpec: [StylePropertySpecification](https://docs.maptiler.com/sdk-js/api-reference/types/StylePropertySpecification/) | null
    -   `Optional`globalState: [Record](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.Record/)<string, any\>
    
    #### Returns [Result](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.Result/)<[StyleExpression](https://docs.maptiler.com/sdk-js/api-reference/classes/StyleExpression/), [ExpressionParsingError](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.ExpressionParsingError/)\[\]\>
    
    #### Private[](#private)
