Get the App
SLTechnology News&Howtos  ›  Development  › 

Analysis of JavaScript dynamic types, string values and numerical examples

Shulou Source: shulou.com Published: 2022-06-01 05:18:27 10月02日 Update

This article introduces the relevant knowledge of "JavaScript dynamic type, string value, numerical example analysis". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

JavaScript has dynamic types

JavaScript has dynamic types. This means that the same variable can be used as different types:

Example

Var x; / / now x is undefined

Var x = 7; / / now x is a numeric value

Var x = "Bill"; / / now x is a string value

JavaScript string value

A string (or text string) is a string of characters (such as "Bill Gates").

The string is surrounded by quotation marks. You can use single or double quotation marks:

Example

Var carName = "Porsche 911"; / / use double quotation marks

Var carName = 'Porsche 911'; / / use single quotation marks

You can use quotation marks within a string, as long as they do not match the quotation marks that surround the string:

Example

Var answer = "It's alright"; / / single quotation marks within double quotation marks

Var answer = "He is called 'Bill'"; / / single quotation marks within double quotation marks

Var answer ='He is called "Bill"; / / double quotation marks within single quotation marks

JavaScript value

JavaScript has only one numeric type.

You can write a value with or without a decimal point:

Example

Var x1 = 34.00; / / with decimal point

Var x2 = 34; / / without decimal point

Very large or ultra-small values can be written by scientific counting:

Example

Var y = 123e5; / / 12300000

Var z = 123eMur5; / / 0.00123

This is the end of the content of "JavaScript dynamic type, string value, numerical example analysis". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Tags: Quotation marks characters strings instances numeric marks types dynamic decimal decimal case analysis analysis content more knowledge different practical the same learned and then no Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information MariaDB Xiaomi Microsoft OPPO Reno