Home declaring a variable with colon in JavaScript
Reply: 1

declaring a variable with colon in JavaScript

Semooze
1#
Semooze Published in 2018-01-11 03:35:25Z

Hi right now i'm learning JavaScript. There is a confusion with some JavaScript I just found. This is the source code

import type { OptionsType } from 'Types'

const theme: OptionsType = {
  title: 'Lawton',
  baseFontSize: '16px',
  baseLineHeight: 1.5
}

In the code, the const variable is declared with ":"

What does ":" mean in the expression ?

Is it equivalent with

const theme = OptionsType = { title: 'Lawton' }
basarat
2#
basarat Reply to 2018-01-11 04:22:01Z

What does ":" mean in the expression ?

This is FlowType. Checkout the docs on the annotation: https://flow.org/en/docs/getting-started/

More

This is not TypeScript as import type is a flow thing: https://flow.org/en/docs/types/modules/#importing-and-exporting-types-a-classtoc-idtoc-importing-and-exporting-types-hreftoc-importing-and-exporting-typesa

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.246883 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO